Visit Jeremy's Blog.
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 12-13-2004, 01:27 PM   #1
LQ Newbie
Registered: Dec 2004
Posts: 1

Rep: Reputation: 0
Persistent iptables? Where to save the script?


First a bit of background: I've had a dedicated server for about 3 years and am used to basic remote adminisitration. The GUI and other features are actually a bit overwhelming...I find myself in terminal pretty often.

At any rate, I'm trying to setup a basic forwarding for my home network. It's run of the mill and it works but is not persistent after reboot or restart. Here is the script I'm using (courtesy of
# Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.
   iptables --flush            
   iptables --table nat --flush
   iptables --delete-chain     
   iptables --table nat --delete-chain

   # Set up IP FORWARDing and Masquerading
   iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
   iptables --append FORWARD --in-interface eth1 -j ACCEPT

   echo 1 > /proc/sys/net/ipv4/ip_forward
Right now I have it saved as an executable and if I reboot I come back and execute. The question I have is how do I execute this script at boot? Can I include it in a rc.d/file?

Now, I want to apologize to all the vets for such a simple question. I have UFSB and read 14 pages of threads as they releate to "gateway". Most are asking how to troubleshoot their networks and iptables for access. I did not find one explaining how to make a currenty working homenetwork persistent after reboot.

I am using CentOS v3.3 with 2 NIC's. eth0 -> internet, eth1 -> internal

All settings are good on boot (homenetwork functional, external access is good) but the forwarding has to be setup with the script above.


Old 12-13-2004, 01:41 PM   #2
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
Well.... I have that kind of stuff (things that have to happen at boot time) at the rc.local file. I think that's the quasi-standard place to do that (in a RH-based distribution).


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
Save iptables filters yhus Red Hat 3 07-30-2005 05:01 AM
Where should I save this iptables? wardialer Linux - Newbie 2 02-12-2005 05:10 AM
Priority: script to run on boot vs. "service iptables save" iheardrain Linux - General 5 09-30-2004 10:53 PM
iptables save rules Osten Debian 1 02-10-2004 05:53 PM
Iptables-save ??? gruger Linux - Security 3 05-23-2003 07:23 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:19 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration