Complete Guide to DHCP Server Configuration on Ubuntu

Ubuntu DHCP Server Configuration Complete Steps

A DHCP (Dynamic Host Configuration Protocol) server is a network protocol and software service used to automatically assign IP addresses and other network configuration information to devices in a network without manual intervention. Imagine you have multiple clients on your network that need IP addresses and network configurations to establish connections with each other and access the internet. Manually assigning IP addresses and network configurations to each device is a tedious, time-consuming, and error-prone process. Therefore, when you configure an Ubuntu DHCP server, it acts as a central point for managing and automating the assignment of IP addresses, becoming an essential component in many network environments. So, devices dynamically and automatically receive IP addresses and relevant network configuration information from this server.

Configuring a DHCP server in Ubuntu involves several simple steps, which are explained in this article. By the end of this guide, you will have an active ubuntu DHCP server, making it significantly easier to manage and assign IP addresses to the clients on your network.

Understanding the Function of a DHCP Server

A brief explanation of how the DHCP server works helps to better understand the efficiency of this server:

Typically, devices connecting to a network do not have an assigned IP address or network configuration information. To establish communication with each other and access the internet, these devices send a DHCP Discover message to the DHCP server to request network configuration details.

In the network, the DHCP server receives the DHCP Discover message from the device and begins to examine its set of available IP addresses and other configuration settings. If an IP address is available for lease, the server responds to the requesting device with a DHCP Offer message. This message contains the IP address to be assigned to the requesting device and network configuration information such as subnet mask, gateway, DNS servers, lease duration, and more.

The requesting device receives the DHCP Offer and sends a DHCP Request message to confirm its selection of the DHCP server’s offer.

Ultimately, after receiving the DHCP confirmation message, the device applies the network settings based on the information provided by the DHCP server, assigns the IP address, and becomes eligible to establish communication within the network.

The DHCP server administrator configures a specific time duration for each lease because DHCP leases are temporary. Devices must renew or request a new IP address before the lease expires.

To ensure an efficient IP address leasing mechanism and prevent IP address conflicts, DHCP servers record the assigned IP addresses. Additionally, To improve the DHCP server’s performance, it’s advisable not to have more than one DHCP server in your network.

Why Set Up a DHCP Server on Ubuntu?

There are several important reasons for setting up a DHCP server in a network environment. Here, we will discuss the main reasons for configuring Ubuntu DHCP server:

  • Automatically assign IP addresses to devices in the network.
  • Efficient resource management in large networks by reclaiming and reallocating IP addresses when devices are powered off or disconnected.
  • Providing crucial network configuration parameters to devices connected to the network and facilitating device configuration.
  • Enabling network segmentation and enhancing security.
  • Centralized control over IP address allocation and network settings.
  • Setting up multiple DHCP servers for redundancy and taking over the management by another server with the failure of one server and guaranteeing minimum network failure
  • Dynamically updating DNS records to ensure devices are accessible by name within the network.

Prerequisites for Setting Up a DHCP Server Ubuntu

Before configuring an Ubuntu DHCP server, consider the following prerequisites to ensure the correctness and success of the DHCP Server configuration:

  • Have an Ubuntu VPS to host the DHCP server software.
  • Ensure the correct configuration of your Ubuntu server with a static IP address, subnet mask, and gateway.
  • Have root or sudo access to the server.
  • Ensure the network infrastructure, including switches and routers, is in place to facilitate DHCP traffic flow.
  • Use a preferred text editor, such as Nano, Vim, etc., for editing configuration files.
  • Create backups of your existing configuration files before making any changes.
  • Take note of your network interface card for establishing connections to clients (use the “ip a” command to identify it).

Quick Guide to Ubuntu DHCP Server Configuration

After considering the necessary prerequisites, let’s now focus on how to configure a DHCP server on Ubuntu:

1. Update the Ubuntu package list

Before installing the DHCP service on Ubuntu, update the package list on your Ubuntu server:

sudo apt update

2. Install DHCP Server in Ubuntu

Begin by installing the DHCP server package on your Ubuntu server using the apt package manager. Since the “isc-dhcp-server package” is a popular choice, install it on your Ubuntu server by running the following command:

sudo apt install isc-dhcp-server

3. Edit the Configuration File

After completing the DHCP server installation, you need to configure it to handle and respond to requests from devices in the network. The initial configuration file for the DHCP server is located at /etc/dhcp/dhcpd.conf. Before editing the main configuration file, it’s always a good practice to create a backup copy of the DHCP server configuration file. You can do this using the cp or mv commands:

sudo mv /etc/dhcp/dhcpd.conf{,.backup}
#Expands to sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.backup

Next, using your preferred text editor (such as Nano or Vim), open the  /etc/dhcp/dhcpd.conf configuration file to make edits:

sudo nano /etc/dhcp/dhcpd.conf

As you are aware, the primary purpose of setting up a DHCP server in Ubuntu is to provide automatic and dynamic IP address allocation, which is done randomly. Here, we provide a sample configuration file that you should customize according to your network and add your network information to the content of this configuration file to send to clients connected to the network. Here is an example:

option domain-name "";
option domain-name-servers,;
default-lease-time 600;
max-lease-time 7200;

subnet netmask {
option routers;
option subnet-mask;
option broadcast-address;

Configure the subnet block with your network settings.

In our example, we set the default lease time for clients and the maximum lease time (default-lease-time 600; max-lease-time 7200). We specified that the DHCP server will offer IP addresses to devices in the range of to and set as the default gateway and and as the DNS servers for the clients.

4. Configure a Static IP on a DHCP Client

To assign a static IP address to a specific device in the network, you must configure DHCP clients in such a way that the IP and MAC address that they always receive from the DHCP server are clearly defined. First, identify the MAC address of the specific device on the network by running the following command:

ip a

Then, take note of the MAC address of the interface that you intend to connect to the network and add it to the configuration file. For example:

host fedora-node {
hardware ethernet e0:91:41:31:af:ab;

Then, save the file (in Nano, it’s Ctrl+O, then Enter) and exit the file (in Nano, it’s Ctrl+X).

For automatic address allocation, you can remove the “Static IP Configuration” section from the configuration file.

5. Configure the DHCP Server to Use the Correct Network Interface

By default, the DHCP server listens on all available network interfaces. If you want the DHCP server to listen on a specific interface, define the desired interface in the /etc/default/isc-dhcp-server file. You can identify the correct network interfaces by running the “ip a” command on the server. So, after identifying the correct network interface, edit the /etc/default/isc-dhcp-server file with your preferred text editor:

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

Locate the line “INTERFACES=” in the file and specify your desired network interface. For example:


6. Restart the DHCP Server ubuntu

After configuring the server to apply the changes, restart the DHCP service:

sudo service isc-dhcp-server restart


sudo systemctl restart isc-dhcp-server.service

7. Enable IP Forwarding

If you use the DHCP server as a router, you should enable IP forwarding by editing the /etc/sysctl.conf file:

sudo nano /etc/sysctl.conf

To enable IP forwarding, uncomment or add the following lines:


Run the following command to apply the changes:

sudo sysctl -p

8. Firewall Configuration

If you use a firewall, ensure that DHCP traffic on the relevant ports (typically, the DHCP daemon listens on UDP ports 67 and 68) is allowed. For example, if you are using a UFW firewall, execute the following commands for this purpose:

sudo ufw allow 67/udp
sudo ufw allow 68/udp

9. Start DHCP service automatically

To ensure that the DHCP service starts automatically during system boot, run the following command:

------------ SystemD ------------
$ sudo systemctl start isc-dhcp-server.service
$ sudo systemctl enable isc-dhcp-server.service
------------ SysVinit ------------
$ sudo service isc-dhcp-server.service start
$ sudo service isc-dhcp-server.service enable

10. Check the status of the DHCP Server

To ensure the proper functioning of the DHCP server, execute the following command:

sudo systemctl status isc-dhcp-server.service

The “active” status indicates a successful configuration of the DHCP server.

11. Monitor DHCP Server Logs

To troubleshoot any issues, check the DHCP server logs in /var/log/syslog or /var/log/daemon.log:

tail -f /var/log/syslog

By checking DHCP server logs, you can identify and solve issues as soon as possible.


Congratulations, you have successfully configured and set up an Ubuntu DHCP server, and it is ready and active to assign IP addresses to clients on your local network automatically. In summary, DHCP is an automatic IP address distribution system among various clients in your local network. Configuring the DHCP server on Ubuntu leads to network management facilitation, ensuring efficient IP address utilization and overall network performance and management improvement. These features make the DHCP server an essential component in many modern network environments.

This article provides a quick and helpful guide for the initial Ubuntu DHCP Server Configuration. By following these instructions, you can now utilize the Ubuntu DHCP server for various purposes. It’s important to note that you should tailor your configuration to meet your network’s specific requirements and security considerations.If you are using a Windows server, by following the previous guidance, you can transform your Windows server into a centralized point for network control and management, as well as IP address distribution to clients, by configuring a DHCP Server in Windows Server.

If you have any questions or encounter any issues in this regard, feel free to share them with us in the comments section, and we will be responsive to assist you.

Leave a Reply

Your email address will not be published. Required fields are marked.