Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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.
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.
Distribution: Whatever I feel like at the time I install.
Posts: 284
Rep:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.