Set Up DHCP Server on CentOS 8 - How to do it ?

The Dynamic Host Configuration Protocol (DHCP) is a standardized network protocol used on Internet Protocol (IP) networks for dynamically distributing network configuration parameters, such as IP addresses for interfaces and services. With DHCP, computers request IP addresses and networking parameters automatically from a DHCP server, reducing the need for a network administrator or a user to configure these settings manually.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related DHCP queries.

In this context, we shall look into how to set up a DHCP server on CentOS 8.


Steps to Set Up DHCP Server on CentOS 8

1. Perform system update

First, let's start by ensuring your system is up-to-date:

$ sudo dnf clean all
$ sudo dnf update


2. Install a DHCP server on the system

You can Install the DHCP package using the following command:

$ sudo dnf install dhcp-server


3. Configure DHCP server

To configure the DHCP server, edit the /etc/dhcp/dhcpd.conf configuration file with the following command:

$ sudo nano /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;
subnet 192.168.77.0 netmask 255.255.255.0 {
range 192.168.77.21 192.168.15.200;
option routers 192.168.77.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 8.8.8.8, 8.8.4.4;
}

Restart the DHCP service once you are done with doing all the changes:

$ sudo systemctl restart dhcpd
$ sudo systemctl status dhcpd


4. Configure Firewall

We will add the DHCP service to the CentOS 8 firewall and update the rules with the following commands:

$ firewall-cmd --add-port=67/udp --permanent
$ firewall-cmd --reload


5. Configure DHCP Client on the system

You can Install DHCP client package using the following command:

$ sudo dnf install dhcp-client

Then, run dhclient a command to get the DHCP IP:

$ dhclient

Now check the assigned IP addresses.


[Need assistance in setting up DHCP Server on a Linux Virtual Machine ? We can help you. ]

This article covers the process of installing DHCP Server on CentOS 7 system. In fact, Dynamic Host Configuration Protocol (DHCP) is a communication protocol that computers use to automatically assign IP addresses to devices connected to a local network or over the internet. 

Related Posts