How to Set Up and Configure a DHCP Server on Ubuntu Server

Why Run a DHCP Server on Ubuntu?

The Dynamic Host Configuration Protocol (DHCP) automatically assigns IP addresses and network configuration parameters to devices on a network. While many routers have built-in DHCP functionality, running a dedicated DHCP server on Ubuntu Server provides significantly more control, advanced logging, and scalability for complex network environments.

Step 1: Install the isc-dhcp-server Package

Log in to your Ubuntu Server and update your package list. Then, install the DHCP server package by running the following commands in your terminal:

sudo apt update
sudo apt install isc-dhcp-server -y

Step 2: Define the Network Interface

You must tell the DHCP server which network interface to listen on. Open the default configuration file in a text editor:

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

Locate the INTERFACESv4 line and add your network interface name (e.g., eth0 or enp3s0). You can find your interface name using the ip a command.

INTERFACESv4="eth0"

Step 3: Configure the DHCP Pool

Next, configure the IP address pool and network settings. Open the main DHCP configuration file:

sudo nano /etc/dhcp/dhcpd.conf

Scroll to the bottom of the file and add your subnet configuration:

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.200;
  option routers 192.168.1.1;
  option domain-name-servers 8.8.8.8, 8.8.4.4;
  default-lease-time 600;
  max-lease-time 7200;
}

Step 4: Restart and Enable the Service

Save the file and exit the editor. Restart the DHCP service to apply your new configuration, and enable it to start automatically on boot:

sudo systemctl restart isc-dhcp-server
sudo systemctl enable isc-dhcp-server

Step 5: Verify the Service Status

Ensure the service is running without errors by checking its status:

sudo systemctl status isc-dhcp-server

If the service is active (running), your Ubuntu server is now successfully assigning IP addresses to client devices on the network.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.