Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MASQUERADE HELP!

Status
Not open for further replies.

ryansdv

Programmer
Joined
May 19, 2003
Messages
42
Location
PH
Hi! I'm new with Linux. I have a linux gateway with 2 NIC.
In order to share the internet connection of eth0 to eth1 I always run this script below mannually. Please help me were would I put this to automically run everytime I restart.

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

Thank you and more power.
 

It’s depending upon the flavour of Linux you are using. If you use RedHat then it could be placed in the file ‘/etc/rc.local’ Just add those line at the end.

Cheers!!
 
On my Fedora Core 2 box, there's something like /etc/networking/ifup.d/ (something like that). Basically, you put the scripts you want run in there when an interface comes up.

Sorry. I'd be more verbose, but somebody lost their mind and booted my box into Windows for a bit and I'm flying blind ;-) That might get you started in the right direction though.

----
JBR
 
Actually, it you're using fedora you should already have an /etc/init.d script for iptables. If you make the changes you want to your iptables and then issue the command 'service iptables save', then the next time iptables is started with the init script, the state will be restored. That should work in RH, also.
 
Actually I'm using Red Hat, so I'll take the advice of santanudas. And I'll take note also the advice for other linux flavor.

To you all, thank you very much and more power!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top