This page was edited more than a year ago (2007-07-25), content might not be relevant or accurate anymore.

Simple NAT with iptables

iptables -t nat -A POSTROUTING -o eth0 -s -d 0/0 -j MASQUERADE

where is network behind router (PC) and eth0 is interface with connectivity. This iptables rule will allow forwarding packets from NAT-ed devices to any IP address.

In /etc/sysctl.conf enable IPv4 packet forwarding:

# Uncomment the next line to enable packet forwarding for IPv4

You can immediately do this with command:

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

Remember to set correct IP addresses and gateways on the NAT-ed devices.

Back to top
howto/simple_nat_with_iptables.txt · Last modified: 2007/07/25 21:34 (external edit)
disorder's homepage Valid CSS Valid XHTML 1.0 Recent changes RSS feed