If I understand what you're trying to do, you need to install a couple of things:
sudo apt-get install dhcp3-server resolvconf #also possibly 'radvd'
Enabling traffic through you machine (IPv4):
Ok, now let's change a setting:
sudo nano /etc/sysctl.conf
Delete the # from the start of the line #net.ipv4.ip_forward=1
and press Ctrl x, then y to save.
Run sudo sysctl -p
.
Set address for LAN interface (IPv4):
Unless you are 'Computer Sciences Corporation', you should not be using 20.x.x.x addresses. You could use any of the following private addresses ranges instead: 10.x.x.x, 192.168.x.x, or the range 172.16.0.0 – 172.31.255.255 (aka 172.16.0.0/12 or 172.16.0.0 with netmask 255.240.0.0). Run
sudo nano /etc/network/interfaces
Delete the gateway line. This computer is the gateway for the connection, so you do not set a gateway for this interface. Other computers will have this computer's address as their gateway. Change the address line to address 10.0.0.1
. Change the broadcast line to broadcast 10.0.0.255
. Press Ctrl x, then y to save.
Set DNS server (IPv4 and/or IPv6):
Run
sudo nano /etc/resolvconf/resolv.conf.d/head
(ignore the scary warning. /etc/resolv.conf is autogenerated, so the warning is in the /etc/resolvconf/resolv.conf.d/head
file so it will get put at the top of /etc/resolv.conf when /etc/resolv.conf is generated.) To the end of the file, add
nameserver <ip_of_nameserver>
Press Ctrl x and answer yes to saving the file. To finish up, regenerate /etc/resolv.conf so the changes are applied right now:
sudo resolvconf -u
Set up NAT (IPv4)(shudder):
Enable UFW:
sudo ufw enable
Make a persistent NAT rule that is restored at boot by UFW:
sudo nano /etc/ufw/before.rules
Add the line -A POSTROUTING -o ppp0 -j MASQUERADE
after the line *nat
. Press Ctrl x, then y to save.
Give out addresses (IPv4):
Let's edit some files:
sudo nano /etc/dhcp3/dhcpd.conf /etc/default/dhcp3-server
To the first file, add the following:
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.2 10.0.0.254;
option routers 10.0.0.1;
option domain-name-servers <dns_server>;
}
Press Ctrl x, then y to save. In the next file, edit the line INTERFACES=""
to say INTERFACES="eth1"
. Press Ctrl x, then y to save. To start the address handing out daemon, run
sudo /etc/init.d/dhcp3-server start