All commands run should be done with root privs
[The Phyical Setup]
Connect to the first ethernet card (eth0) the line that gets this computer connected to the internet.
Connect to the second ethernet card (eth1) to a hub/switch
Connect all clients to be NAT'ed to the hub/switch.
The NAT'ed network will be 192.168.0.0/24
And the NAT'ing computer will be 192.168.0.1 on eth1
On the NAT'ing computer:
ifconfig eth1 192.168.0.1 netmask 255.255.255.0
Enabling IP Forwarding in the Kernel
Check and see if your computer is already doing forwarding with:
If what it returns is 0, its off
if what it return is 1 then its already enabled.
Turn it on now by running:
sysctl -w net.ipv4.ip_forward=1
and to enable it at boot, add this line to your /etc/sysctl.conf:
net.ipv4.ip_forward = 1
Now restart your networking:
Forwarding Rules in IPTables
iptables -A FORWARD -i eth1 -o eth0 -s 192.168.0.0/24 -m state --state NEW -j ACCEPT iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A POSTROUTING -t nat -j MASQUERADE
Finally setup you clients to have a 192.168.0.0/24 address, with the gateway as 192.168.0.1