I’ve always known Linux was easy to setup as a router but until just now I’d never actually gotten round to figure out how to turn a box into a gateway. I knew how to setup the network side, setting up the routes etc. but the bit where you tell a box to forward packets from one network to another I just never got around to finding. It’s dead simple so I figured I’d better jot it down for the next time.
Edit the /etc/sysctl.conf and uncomment out the net.ipv4.ip_forward=1 line.
To set forwarding right now without a reboot or restart of anything you should then do this,
echo 1 > /proc/sys/net/ipv4/ip_forward
If you’re after a more detailed guide covering setting up your own gateway I found this information from http://technology.ezinemark.com/ubuntu-firewall-router-gateway-31d0966f5c3.html which covers the whole subject in more detail.

