A DHCP server issues computers on the network IP addresses. Normally this is done by the router but a computer is more flexible because:
sudo apt-get install dhcp3-server
Configuring a DHCP server is where most of the complexities and bulk of the work lies. First thing to do is set the network interface should us DHCP. Edit /etc/default/isc-dhcp-server
and change INTERFACES=""
to INTERFACES="eth0"
where eth0 is the network interface. Save and exit the file.
The DHCP server configuration file is located at /etc/dhcp/dhcpd.conf
. It’s probably best to make a backup of the file first
sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.old
Edit the configuration file using the preferred text editor. The remainder of this post will be about configuring the server.
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.2 192.168.1.254;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
option domain-name-servers 208.67.222.222, 208.67.220.220;
}
What they mean:
IP addresses can be reserved so that computers can be assigned the same IP address all the time (except when there’s already assigned). Add the following lines to the bottom of the config file:
host MyComputer {
hardware ethernet AA:11:BB:22:CC:33;
fixed-address 192.168.1.100;
}
Change the above parts highlighted in bold. MyComputer is the name of the computer, hardware ethernet is the MAC address of the network card and fixed-address is the IP address to be reserved.
For the changes to take hold, restart the DHCP server sudo service isc-dhcp-server restart
Setting up the DHCP server was fairly easy but configuring it is a lot harder than using a web interface like almost all routers nowadays. This setup is a precursor to creating a server to replace a router and will be more instrumental when used with other services such as proxy, DNS, etc