Everything below is done as the root user.
Edit the file /etc/sysctl.conf and on the line net.ipv4.ip_forward = 0,
change 0 to 1.
net.ipv4.ip_forward = 1IP forwarding and Masquerading:
$ iptables -F INPUTThe following commands will create new rules for your system.
$ iptables -F OUTPUT
$ iptables -F FORWARD
$ iptables -t nat -F
$ iptables -P INPUT ACCEPTYou may have to switch eth0 and eth1 depending on your setup.
$ iptables -P OUTPUT ACCEPT
$ iptables -P FORWARD DROP
$ iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
$ iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
$ iptables -A FORWARD -j LOG
$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
$ service iptables save.
Done.