Linux Simple NAT

Jump to navigationJump to search


I'm trying to explain how a simple network can share a connection using a linux router. The same router can also serve file sharing, mail server and other stuff to the network.


1) load the ipt_MASQUERADE . Depending on the distro, this could be built in, already loaded or not available. Try continuing even if it fails.

modprobe ipt_MASQUERADE

2) Be sure to flush all the rules in iptables. You can apply yours after you see NAT is working.

iptables -F; iptables -t nat -F; iptables -t mangle -F

3) Enable ip_forwarding in the kernel

echo 1 > /proc/sys/net/ipv4/ip_forward

4) Forward your ips to the one on eth0

iptables -t nat -A POSTROUTING -s -j SNAT -o eth0 --to


Masquerading made simple