These are archived pages, most of them date back to 2007-2012. This 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.

disorder's homepage