Quick source NAT with IPtables

February 2008


[Note]Note

eth0 Is the outside world, eth1 is the private network.

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

  2. iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

  3. iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT

  4. iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT