Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Route iptables and ip_forward help needed

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help!
View previous topic :: View next topic  
Author Message
tommi



Joined: Tue May 17, 2005 8:21 am
Posts: 1

PostPosted: Tue May 17, 2005 8:31 am    Post subject: Route iptables and ip_forward help needed Reply with quote

I have a 2 computer netwrok at home, machine 1 windos xp and machine 2 mandrake 10.1. The mandrake box is acts as the server for the windows machine and shares the internet connection.

My trouble is that everytime the intenet is restarted i have to enter the following 3 commands as su.

iptablles -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
route add default ppp0

What files do i need to edit, to put those commands into so i dont have to manually do this each time.

Thank you for your time and concideration.
Back to top
View user's profile Send private message
jjmac
LXF regular


Joined: Fri Apr 08, 2005 2:32 am
Posts: 1996
Location: Sydney, Australia

PostPosted: Tue May 17, 2005 10:02 am    Post subject: RE: Route iptables and ip_forward help needed Reply with quote

Howdy,

Depends on how you start your networking i guess...

Sounds like it just needs to put into one of your networking start up scripts.

In my case, i allow basic networking to be setup at boot, which is to a console ... then go into run level 2 with starting X. There all extra networking things get killed, such as iptables and sniffers etc. If i want to go onlin, i used to just go into level 3 which would kill a couple of daemons, then run a couple of scripts to set up iptables etc. With the 2.6.10 kernel though, it wont give me any echo feed back when i do a 'telinit 3' ... so now i just run a script to do the same and don't bother with the level change.

Have a look over the scripts invoked when networking is setup your way. Possibly you could slot it into one of those. Such as /etc/init.d/networking. The path might be different though.

jm

Code:

  -:-  If the system is the answer, then the question
                    must have been really stupid                -:-

_________________
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
Back to top
View user's profile Send private message
mugstar
LXF regular


Joined: Mon Apr 11, 2005 1:43 am
Posts: 184
Location: Scotland

PostPosted: Tue May 17, 2005 10:24 am    Post subject: Reply with quote

The comments in /etc/rc.d/rc.local say
Quote:
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

That's where I had to put `ifup eth0`, since mandrake otherwise refused to set up networking at boot. LE2005 seems very flaky to me...
Back to top
View user's profile Send private message
smita034



Joined: Tue Apr 26, 2005 2:13 pm
Posts: 29
Location: Rochester, Kent, UK

PostPosted: Tue May 17, 2005 10:25 am    Post subject: RE: Route iptables and ip_forward help needed Reply with quote

what i would do (again i dont know the paths for this distro so it might be else where) is;

put a script in /etc/rc3.d called S<number>iptables (If i remember correctly you can use any number that isnt in use at the moment, for ease sake, lets say 99)

in the S99iptables file

Code:
#! /bin/sh
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
route add default ppp0
I think this should work but I haven't done it for a while so correct me if im wrong Smile

That should make it automaticly get run @ runlevel 3.

hope that helps
_________________
Alex A. Smith
99% of all computer problems occur between the chair and keyboard
Back to top
View user's profile Send private message
jjmac
LXF regular


Joined: Fri Apr 08, 2005 2:32 am
Posts: 1996
Location: Sydney, Australia

PostPosted: Thu May 19, 2005 1:38 pm    Post subject: RE: Route iptables and ip_forward help needed Reply with quote

Depending how it is setup on your system ... An other idea is to append the file that sets up 'iptables' with something like

-------------------------------------------------------------------------
iptables-save > /home/jmd/common/firewall/ipt-save
chown jmd:jmd /home/jmd/common/firewall/ipt-save
echo -e "\n iptable setup saved to common/firewall dir"
--------------------------------------------------------------------------

Then provide your own customisations. That way you get a dump of how the package facility is setting things, before they are alted by any custom additions.


>>
My trouble is that everytime the intenet is restarted i have to enter the following 3 commands as su.
.
.
.
What files do i need to edit, to put those commands into so i dont have to manually do this each time.
>>

It would be interesting to know just how it is started in the first place ... Your logs in /var/log may have a trace on that. Or putting an 'echo' command in likely looking scripts in 'init.d' may give you a mark for when there run, I know, typo heaven ... but ..., just back the file(s) first, and have a LiveCD handy to 'cp' the backup back to where it should be if necessary.

A good startup script, imo, should save the existing state, then destroy any existing configuration ... then recreate/initialise the whole thing. Rather than just doing it once when you bootup, or go into X.

If the iptables side is started/handled by a package of some sought ... listing its contents should reveal any scripts that are being used there.

Even just looking through /usr/sbin or /sbin for anything that loks like it might be involved would be an idea. The thing with iptables and such ... there are a number of various ways to go about it depending on preferences.

>>
echo 1 > /proc/sys/net/ipv4/ip_forward
route add default ppp0
>>

That sounds like the type of thing that could be started at boot via an .../init.d/network script, but an iptables script will often involve itself there as well.


jm

Code:


     -:-  If the system is the answer, then the question
                     must have been really stupid                  -:-

_________________
http://counter.li.org
#313537

The FVWM wm -=- www.fvwm.org -=-

Somebody stole my air guitar, It happened just the other day,
But it's ok, 'cause i've got a spare ...
Back to top
View user's profile Send private message
tomulli
Guest





PostPosted: Fri Jul 01, 2005 12:48 am    Post subject: RE: Route iptables and ip_forward help needed Reply with quote

for enabling iptables in runlevels write:
>>
chkconfig --add --level 235 iptables on
>>

for enabling ip_forwarding after reboot in RedHat like systems (i just test it on friends MDK 10.1)add

>>
FORWARD_IPV4=true
>>

into /etc/sysconfig/network


and for saving iptables rules use

>>
/etc/init.d/iptables save
>>

good luck

tomulli
Back to top
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help! All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast