How to Setup a DHCP Server on Ubuntu 18.04
Setting up a Dynamic Host Configuration Protocol (DHCP) server with Linux is easy and this tutorial will show you how to configure a DHCP server on a clean install of Ubuntu Linux 18.04.
Network
In this tutorial, the Ubuntu server is configured with a static IP address of 10.1.1.243
and I’ll be using the following network settings for the DHCP server. You can adjust them as you see fit.
Network: 10.1.1.0
IP address: 10.1.1.243
Subnet: 255.255.255.0
DCHP Range: 10.1.1.101 - 10.1.1.200
Login to the Ubuntu Server via SSH and then we’ll begin.
Step 1: Install DHCP Server
The first thing we need to do is install the dhcpd server by running the following command:
sudo apt install isc-dhcp-server -y
Step 2: Configure the DHCP Server
Open the dhcpd.conf
file with your favorite text editor.
sudo vim /etc/dhcp/dhcpd.conf
Change the domain name and name servers options.
option domain-name "example.lab";
option domain-name-servers 10.1.1.2;
Uncomment authoritative;
because it will be the only DHCP server on the network.
authoritative;
Add the following subnet config to the bottom of the file.
subnet 10.1.1.0 netmask 255.255.255.0 {
range 10.1.1.101 10.1.1.200;
option routers 10.1.1.2;
}
Apply the changes by running the command:
sudo systemctl restart isc-dhcp-server.service
Step 3: Test a client
Check to see if a client on the same network with its adapter set to DHCP can obtain an IP address. As you can see in the screenshot below, a Windows 10 virtual machine on the same network has been assigned an IP address of 10.1.1.135
.

Running the dhcp-lease-list
command also confirms this.
ubuntu@ubuntu:~$ dhcp-lease-list
To get manufacturer names please download http://standards.ieee.org/regauth/oui/oui.txt to /usr/local/etc/oui.txt
Reading leases from /var/lib/dhcp/dhcpd.leases
MAC IP hostname valid until manufacturer
===============================================================================================
00:0c:29:45:ba:4d 10.1.1.135 DESKTOP-8UK989 2019-12-12 13:22:00 -NA-
Creating Fixed IP addresses
It’s possible to assign a static address to a machine using the DHCP server instead of manually assigning it on the machine. This is useful for servers and printers, where you don’t want the IP address to change.
To configure a static IP, you need to know the MAC address of the machine, and the IP address must not be in the DCHP range. Add the following to the dchpd.conf
to create a fixed IP.
host esxi02 {
hardware ethernet 00:0c:29:c0:a0:19;
fixed-address 10.1.1.12;
}
In the example above, I’m assigning the hostname of esxi02
and and IP address of 10.1.1.12
to a server that has a network card with the MAC address of 00:0c:29:c0:a0:19
.
That’s it
You should now have a Ubuntu Server 18.04 machine on your network that will assign IP addresses to clients. We also covered how to create a fixed IP address so that you don’t have to manually configure static addresses on each server.
Tips:
- If you have any problems with clients not being able to obtain an address from the DHCP pool check the
syslog
file located at/var/log/syslog
for any clues. - You can also run the
dhcp-lease-list
command to see a list of clients with leased addresses from the DHCP pool. - Fixed IP addresses won’t show up in the dhcp lease list.