Install and configure DHCP server and client on CentOS 8 / RHEL 8

This guide will guide you through the steps of installing a DHCP server and DHCP client on a CentOS 8 / RHEL 8 Linux server. If your question is how to install and configure a DHCP server on CentOS 8 / RHEL 8? Then this guide is for you. A DHCP server deployed in your organization does make your network management a breeze. You can rest assured that you manually assign an IP address on each computer in your organization, and letting a DHCP server perform this task can become boring and needlessly repeated.

In this guide, we will install and configure a DHCP server and client on a CentOS 8 / RHEL 8 computer. We will cover the server-side setup and all the client configurations required. Let’s start configuring a DHCP (Dynamic Host Configuration Protocol) server to assign IP addresses to client hosts in the local network.

Step 1: Install a DHCP server on CentOS 8 / RHEL 8

Use the dnf installer to install the DHCP server package.

                        sudo dnf -y install dhcp-server 

This will install any dependencies needed to run a DHCP server on CentOS 8 / RHEL 8.

Step 2: Configure the DHCP server on CentOS 8 / RHEL 8

Edit the DHCP server configuration file on CentOS 8 / RHEL 8.

                        sudo vi /etc/dhcp/dhcpd.conf 

My configuration file will be populated with the following parameters:

  • Domain name:
  • DNS server:
  • DHCP network:
  • DHCP subnet mask:
  • IP address range to be assigned:
  • Default gateway:
  • DHCP lease time: 600
  • Maximum DHCP lease time: 7200

The DHCP server configuration file is as follows:

                        # Set DNS name and DNS server's IP address or hostname
option domain-name     "";
option domain-name-servers;

# Declare DHCP Server

# The default DHCP lease time
default-lease-time 600;

# Set the maximum lease time
max-lease-time 7200;

# Set Network address, subnet mask and gateway

subnet netmask {
    # Range of IP addresses to allocate
    range dynamic-bootp;
    # Provide broadcast address
    option broadcast-address;
    # Set default gateway
    option routers;

After making changes in the configuration file, start and enable the dhcpd service.

                        sudo systemctl enable --now dhcpd

If a firewall is running, allow access to the service port from the network.

                        sudo firewall-cmd --add-service=dhcp --permanent 
sudo firewall-cmd --reload

Step 3: Configure the DHCP client

Install a DHCP client on a Linux machine to obtain an IP address automatically.

                        ----------- CentOS 8 / RHEL 8 / Fedora -----------
$ sudo dnf -y install dhcp-client 

----------- CentOS 7/6 -----------
$ sudo yum -y install dhcp-client

Manually requesting a DHCP IP address

You can use the dhclient command to manually request an IP address.

                        $ sudo dhclient 
$ sudo dhclient eth0

# Confirm
$ ip ad
1: lo: 
                             mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: 
                               mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:10:47:63 brd ff:ff:ff:ff:ff:ff
    inet brd scope global noprefixroute dynamic eth0
       valid_lft 3594sec preferred_lft 3594sec
    inet6 fe80::5054:ff:fe10:4763/64 scope link 
       valid_lft forever preferred_lft forever

Persistent configuration-CentOS / RHEL / Fedora with systemd

  • Edit configuration using nmcli
nmcli connection modify ${ifname} ipv4.method auto
nmcli connection down ${ifname}; nmcli connection up ${ifname}
  • Editing network configuration files manually
                        $ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

Persistent Configuration-Debian

                        $ sudo nano /etc/network/interfaces
iface ens3 inet dhcp

$ sudo systemctl restart [email protected]

Persistent Configuration-Ubuntu

                        $ sudo nano /etc/netplan/01-netcfg.yaml
  version: 2
  renderer: networkd
      dhcp4: yes

$ sudo netplan apply 

For Windows users, check “Configure Windows client to obtain IP from DHCP server”.

Reserve IP address on DHCP server

If you have a MAC address, you can reserve an IP address for a computer or device on your network:

                        $ sudo vi /etc/dhcp/dhcpd.conf
# Add lines like below for each host
host myserver {
    hardware ethernet 00:50:56:8c:20:fd;

Related guidelines:

Install and configure a DHCP server on Windows Server 2019

How to add an FTP site on Windows Server 2019

How to set up a TFTP server on CentOS 8 / RHEL 8 Linux

How to configure iSCSI Initiator on CentOS 8 / RHEL 8

Related Posts