This is applicable for Red Hat Enterprise Linux/CentOS 3 and above.
There are a few ways to set up a Linux machine to route. Here is a relatively straight forward and common method. This method requires that the system use iptables for Network Address Translation (NAT).
To enable packet forwarding:
echo "1" > /proc/sys/net/ipv4/ip_forward
To make this permanent, set the variable net.ipv4.ip_forward = 1 in the /etc/sysctl.conf file. For example:
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
Next, have iptables handle Network Address Translation:
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
where eth0 is "outside" or in public connection. Iptables ruleset should be tuned to be more restrictive. Do not forget to save iptables settings with:
service iptables save
See additional articles in the Knowledgebase for additional iptables configuration and tips.
To view the routing table use:
netstat -rn
To view iptables ruleset use:
iptables -L