Legal:
This document is copyright Jim Brooks © 2002.
Permission to copy, distribute, link, and reformat is given on condition that authorship is indicated.
What if you have several computers networked in a local intranet and want to connect them to The Internet? Instead of buying modems for each one, you can configure a Linux box as a gateway in order to share an Internet connection.
You will need a 2.4 kernel compiled with Netfilter
(AFAIK, it's already compiled in stock kernels from Red Hat, Mandrake, etc).
Enable IP masquerading on the Linux box with the Internet connection (turning it into a gateway):
modprobe iptable_nat
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
The above lines can be added to /etc/rc.d/rc.local
Then, on each of the other computers, add a default route to the Linux gateway. This route command causes all packets destined outside of the intranet to be routed (by default) to the Linux gateway.
route add default gw n.n.n.n [Linux]
route add default n.n.n.n [BSD]
n.n.n.n is the IP address of the Linux gateway.
That should do it.
© 2002,2004 Jim Brooks home
Last modified: Wed Jan 2 14:11:21 EST 2008