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 192.168.0.0/24 -d 0/0 -j MASQUERADE

where 192.168.0.0/24 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

net.ipv4.conf.default.forwarding=1

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