Configure DHCP on Linux

Instructions on how to start a DHCP server in Linux using Ubuntu.

Prerequisites

1 – Linux machine, in this case running Ubuntu 14.04

2 – Superuser privileges or root

Steps to Configure DHCP on Linux

1 – Install DHCP server by typing

$ sudo apt-get install isc-dhcp-server

2 – Allow some time for the installation to complete.

3 – Once it has completed, type

$ sudo nano /etc/dhcp/dhcpd.conf

This is the configuration file and there are a lot of scenarios pre populated here

4 – Locate option domain-name “example.com” and replace example with your domain, if this is what you require.

5 – Locate option domain-name-servers example.local and replace example with the search domain of your choice.

6 – Also, look for the command #authoritative. Uncomment this as this will be the official DHCP server for your network.

7 – Finally, you need to add these settings for you local LAN. In most cases you will be able to find an example configuration and use that.

subnet 192.168.1.1 netmask 255.255.255.0
{range 192.168.1.2 192.168.1.253;

option routers 192.168.1.254; # this is the router address for your network

option domain-name-servers 8.8.8.8;

option domain-name “example.com”; # replace with something for your network}

8 – Once you have done all this type $ sudo service isc-dhcp-server restart.

9 – Test by attaching a computer set to DHCP to check that it receives the address 192.168.1.2 and that the options are correct.
For example, DNS = 8.8.8.8 and Router = 192.168.1.254.