Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 05-15-2003, 08:58 AM   #1
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Rep: Reputation: 30
NAT startup question

Hi all,

I have an RH 8 box acting as my gateway, DNS server, sendmail server, Samba server, etc.). One thing that I find annoying is that if I happen to reboot this machine, I lose internet access from all the other Windows machines until I run the following 2 commands:

# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# echo 1 > /proc/sys/net/ipv4/ip_forward

After that, internet access from all the other computers on the network runs fine. My question is this. How can I get these two things to startup when the computer is booted so I won't have to manually run the commands every time? Thanks all!

Old 05-15-2003, 09:30 AM   #2
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
AFAIR one of the /etc/rc.d/init.d scripts is responsible for firewall setting (look for a script with a name like 'firewall' or something like this:)
next if you found it you see the script executes command 'iptables-restore <file_name'
this is the files name which need to be changed with the command 'iptables-save>file_name'
regarding the "echo..." put it anywhere in the booting scripts, for instance in the same 'firewall' script.
Old 05-15-2003, 10:17 AM   #3
LQ Guru
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Short of that not working you can place commands in an rc.local file (usually located in /etc/rc.d but sometimes symlinked in /etc/rc.local). They will be executed before anyone logs in, during system startup.

Old 05-15-2003, 10:34 AM   #4
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Original Poster
Rep: Reputation: 30
Thanks guys,

I'll check that stuff out and let you know here. MasterC, good seeing you again!

Old 05-15-2003, 10:47 AM   #5
Registered: Feb 2002
Location: Orlando
Distribution: Whatever I feel like at the time I install.
Posts: 284

Rep: Reputation: 30
What I did was I created a full router/firewall script and put it into my root dir and then edited the /etc/init.d/network script which is where the NICs are loaded on setup to lauch my script. However since you are running only two commands I would suggest just editing that file and putting the two lines before the stop command. This way as soon as the NICs are loaded so is the internet for the rest of your network.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nat Question keefaz Linux - Networking 3 08-25-2008 03:55 AM
NAT and DNS Question whohasit Linux - Networking 1 07-19-2005 10:29 PM
nat question gubak Linux - Networking 2 03-01-2005 06:54 AM
a simple (?) NAT question Sarinyo Linux - Security 2 10-20-2004 02:50 AM
please confirm NAT question. musicman_ace Linux - Networking 3 06-02-2004 02:43 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration