Install DHCP Server in Ubuntu 16.04

DHCP, abbreviation of Dynamic Host Control Protocol, is a network protocol that assigns IP addresses automatically to client systems in the network. This reduces the tedious task of manually assigning IP addresses in a large network that has hundreds of systems. We can define the IP range (Scopes) in the DHCP server, and distribute them across the network. The client systems in the network will automatically get the IP address.

In this tutorial, we will see how to install DHCP server in Ubuntu 16.04 LTS server, and configure the DHCP clients.

Install DHCP Server in Ubuntu 16.04 LTS server

For the purpose of this tutorial, I will be using the following system as DHCP server.

My DHCP Server:

OS – Ubuntu 16.04 LTS 64 bit

IP Address – 192.168.1.105/24

Hostname – ubuntuserver.ostechnix.lan

Open Terminal and run the following command to install DHCP server:

sudo apt-get install isc-dhcp-server

Install DHCP server in Ubuntu

DHCP server has been installed. Now, let us go further and configure it to suit our needs.

Configure DHCP server

The default configuration file of DHCP server is /etc/default/isc-dhcp-server. We need to edit and modify it as per our requirements.

If you have more than one Network interface card in your DHCP server, you need to mention on which interface should the DHCP server serve DHCP requests.

As I have only one NIC in my server, I assigned ‘enp0s3’ as the listening interface. Here, enp0s3 isnetwork card’s name.

To do so, edit /etc/default/isc-dhcp-server configuration file:

sudo vi /etc/default/isc-dhcp-server

Assign the network interface:

[...]
INTERFACES="enp0s3"

If you have more than one interfaces, mention them with spaces, for example “eth0 eth1”.

Save and close the file.

Then, edit dhcpd.conf file,

sudo vi /etc/dhcp/dhcpd.conf

Modify it as shown below. Replace the domain name with your own values.

As you see in the above configuration, I have assigned IP range from 192.168.1.150 to 192.168.1.200. So, the DHCP clients will get the IP address from this range. But, what if you want assign a specific IP (fixed IP address) to a particular client? It’s easy too. You can easily assign a specific IP to a client of your network by adding the MAC id of that client with fixed IP address as shown below.

For example, let us say we want to assign IP 192.168.1.160 to client that has MAC id 00:22:64:4f:e9:3a. To find out the IP ann MAC addresses, use ‘ifconfig’ command.

You will see a new IP address from IP range, which we defined in the DHCP server, is assigned to your client system.

As you see in the above screenshot, My Ubuntu 16.04 LTS desktop system, which has MAC id 08:00:27:13:14:d5, has been assigned with a fixed IP address (192.168.1.160) from the DHCP server. Remember we have mentioned these values in dhcpd.conf file of our DHCP server.

Hello everyone! Have a question about multiple DHCP servers in LAN. If i create DHCP server on my new VM, and another DHCP server already exist in same LAN, how should i configure my new server to make thouse DHCP do not interfier each other.