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 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.

 
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