Tuesday, April 6, 2010

How to setup Linux as a NAT router

I'm pretty sure this is all you need:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward

Of course, you obviously have to have iptables installed for this to work. I got it working on my Arch Linux and my Opensuse 11.1.

Your mileage may vary. Please post comments for any suggestions or problems with this little hack.

No comments: