LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Persistent iptables? Where to save the script? (https://www.linuxquestions.org/questions/linux-networking-3/persistent-iptables-where-to-save-the-script-265967/)

GbyteSupport 12-13-2004 12:27 PM

Persistent iptables? Where to save the script?
 
Hello,

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 yolinux.com):
Code:

# 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.

Help?

Bobby

eantoranz 12-13-2004 12:41 PM

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).


All times are GMT -5. The time now is 05:11 AM.