Install and Configure DHCP Server in Ubuntu

In this tutorial we are going to learn How to Install DHCP Server on Ubuntu Server 16.04. At the end of this tutorial you should be able to configure your Ubuntu Server as DHCP server and issue dynamic IP Address to the DHCP clients on your Network.

Install isc-dhcp-server Package on Ubuntu

The DHCP Server for Ubuntu 16.04 provides by the isc-dhcp-server package.

Install the isc-dhcp-server on Ubuntu 16.04 using apt-get install command.

sudo apt-get install isc-dhcp-server

Install and Configure DHCP Server in Ubuntu

Now we have installed the dhcp server on Ubuntu, Next step is to configure Ubuntu dhcp server to assign Dynamic IP Address to the dhcp clients in our network.

Configure Ubuntu DHCP Server

The /etc/dhcp/dhcpd.conf file is the main configuration file for the Ubuntu DHCP Server.

Following is the sample configuration use in /etc/dhcp/dhcpd.conf to issue dynamic IP Address on Specific Subnet.

subnet 10.0.0.0 netmask 255.255.255.0 {
 range 10.0.0.100 10.0.0.150;
 option domain-name-servers 8.8.8.8;
 option subnet-mask 255.255.255.0;
 option routers 10.0.0.1;
 default-lease-time 43200;
 max-lease-time 86400;
}

As per the Above DHCP Configuration,

  • The dhcp server on Ubuntu will assign dynamic IP Addresses to the clients on the 10.0.0.0/24 network.
  • range 10.0.0.100 10.0.0.150 - range option is used to specify the IP Address pool. The Ubuntu DHCP server will use this IP range to issue IP Addresses to the Client Computers.
  • option domain-name-servers 8.8.8.8 - DHCP clients will use the DNS Server 8.8.8.8.
  • option routers 10.0.0.1 - This is the default gateway. The dhcp clients will use the 10.0.0.1 as the default gateway.

You need to restart the dhcp server after you edit the configuration file.

systemctl restart isc-dhcp-server

If your Ubuntu Server is connected to multiple networks, you can add configuration blocks for the each subnet.

subnet 10.0.0.0 netmask 255.255.255.0 {
 range 10.0.0.100 10.0.0.150;
 option domain-name-servers 8.8.8.8;
 option subnet-mask 255.255.255.0;
 option routers 10.0.0.1;
 default-lease-time 43200;
 max-lease-time 86400;
}

subnet 192.168.1.0 netmask 255.255.255.0 {
 range 192.168.1.200 192.168.1.240;
 option domain-name-servers 8.8.8.8;
 option subnet-mask 255.255.255.0;
 option routers 192.168.1.1;
 default-lease-time 43200;
 max-lease-time 86400;
}
  • The dhcp logs available in /var/log/syslog file.
  • The dhcp lease history is stored in /var/lib/dhcp/dhcpd.leases file which contains Active and previous DHCP leases.

Start/Restart DHCP Server in Ubuntu

Start ubuntu dhcp server

systemctl start isc-dhcp-server

Restart ubuntu dhcp server

systemctl restart isc-dhcp-server

Summary - Ubuntu Server DHCP Configuration

In this tutorial we learned how to configure dhcp server on Ubuntu 16.04.

  • The dhcp server for Ubuntu Linux provides by the isc-dhcp-server package which we can install using the apt-get install command.
  • To Assign Dynamic IP Address we added the dhcp configuration to the /etc/dhcp/dhcpd.conf file.
submit to reddit