Monday, April 20, 2009

Enable NAT on Linux|Configure NAT on Linux

NAT enabling is suitable when a Linux Box works as a router.

Assuming that, the Linux box has two network interface with the following parameters.

eth0: IP Address 192.168.10.1/24, connected with Local LAN.
eth1: IP Address 203.200.160.226/29, connected with WAN, Gateway: 203.200.160.225/29

To enable NAT for the Local Private LAN, iptables can be used.
Command is: iptables -A POSTRUTING -t nat -s 192.168.10.0/24 -o eth1 -j MASQUERADE
Note: This will work if,
1) the Linux Box is already configured to work as router.
2) the firewall don't block the packets from Private LAN to WAN.

No comments: