eth0 = the network adapter with internet (external or WAN).
eth1 = the network adapter to which a second computer is attached (internal or LAN).
192.168.0.x = IP subnet for eth1
sudo iptables -A FORWARD -o eth0 -i eth1 -s 192.168.0.0/24 -m conntrack –ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack –ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE
Enable routing
Configure the gateway for routing between two interfaces by enabling IP forwarding:
sudo sh -c “echo 1 > /proc/sys/net/ipv4/ip_forward”
Edit /etc/sysctl.conf and add these lines:
net.ipv4.conf.default.forwarding=1
net.ipv4.conf.all.forwarding=1
