×


Install DHCP Server Client on Centos

Are you trying to install DHCP Server on your CentOS Server?

This guide is for you.


A DHCP Server is a network server that automatically provides and assigns IP addresses, default gateways and other network parameters to client devices. 

It relies on the standard protocol known as Dynamic Host Configuration Protocol or DHCP to respond to broadcast queries by clients.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Software Installation tasks on their CentOS machines.

In this context, we shall look into the steps to install DHCP on CentOS.


More information about DHCP?

DHCP stands for Dynamic Host Configuration Protocol. Basically, Dynamic Host Configuration Protocol (DHCP) determines if an IP is static or dynamic. 

Also, with DHCP enabled means it is letting the DHCP server assign the computers IP.

If your organization has DHCP Server deployed, then the network management would be easy.


How to install a DHCP server on CentOS?

To install DHCP, simply follow the steps given below;


1. Start by installing the DHCP server package using the DNF installer. Execute the command below to do this;

$ sudo dnf -y install dhcp-server

This will install any dependency that is necessary to run the DHCP Server on CentOS 8/RHEL 8.


2. Next, configure the DHCP server by editing the DHCP server configuration file on CentOS 8 / RHEL 8. To do this, execute;

$ sudo vi /etc/dhcp/dhcpd.conf

The configuration file will display different parameters. You can make the necessary changes in it.

Then, start and enable the DHCP server once you make the necessary changes in the configuration file.

$ sudo systemctl enable --now dhcpd

In case, if you have the firewalld running then allow the service port to be accessible from your network.

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

3. Now configure the DHCP client. For that, install a DHCP client in your Linux machine to get an IP address automatically.

----------- For CentOS 8 / RHEL 8 / Fedora -----------

$ sudo dnf -y install dhcp-client

----------- For CentOS 7/6 -----------

$ sudo yum -y install dhcp-client

Also, you can manually request the DHCP IP address. For that run the below command.

$ sudo dhclient <interface>

For instance: $ sudo dhclient eth0


– Persist configurations – CentOS / RHEL / Fedora with systemd

Edit configurations with nmcli

ifname="eth0"
nmcli connection modify ${ifname} ipv4.method auto
nmcli connection down ${ifname}; nmcli connection up ${ifname}


Manually edit the network configuration file

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
PERSISTENT_DHCLIENT="yes"

Persist configurations – Debian

$ sudo nano /etc/network/interfaces
iface ens3 inet dhcp
$ sudo systemctl restart ifup@ens3


Persist configurations – Ubuntu

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

Then finally, run the following command to apply changes;

$ sudo netplan apply

[Need urgent assistance with CentOS Software or Package Installation? – We are here to help you.]


Conclusion

This article will guide you on the steps to install and configure a DHCP server on CentOS 8.