DHCP (Dynamic Host Configuration Protocol) is used to automatically assign IP addresses to PCs and other network devices so that they can communicate. It uses port 67 of the UDP protocol and UDP port 68 for the client. DHCP operations are divided into four phases: server discovery, IP lease quote, IP lease request, and IP lease acknowledgement. These phases are often abbreviated to DORA and are used for discovery, provision, request, and validation. System environment Centos8

192.168.43.254/24. The default gateway is 192.168.43.2/24. The DHCP server will automatically assign IP addresses to other devices in the 192.168.43.0/24 network.

The following is the address information of the DHCP server:

/ root @ localhost ~ # cat/etc/sysconfig/network – scripts/ifcfg – ens160 Centos8 how to configure the DHCP server Centos8 how to configure the DHCP server The following installation DHCP service:

[root@localhost ~]# dnf-y install dhcp-server Centos8 How to configure DHCP server Centos8

The main configuration file for the DHCP server is /etc/dhcp/dhcpd.conf. By default, the file only comments, tips can refer to/usr/share/doc/DHCP server/DHCPD. Conf. Example to modify the configuration file. DHCP/DHCP/DHCP/DHCP/DHCP/DHCP/DHCP/DHCP/DHCP/DHCP/DHCP/DHCP

[root@localhost ~]# cat /etc/dhcp/dhcpd.conf

DHCP Server Configuration file.

see /usr/share/doc/dhcp-server/dhcpd.conf.example

see dhcpd.conf(5) man page

default-lease-time 600; max-lease-time 7200; ddns-update-style none; authoritative; Subnet netmask 255.255.255.0 {range 192.168.43.101 192.168.43.200; Option routers 192.168.43.2; Option subnet configures – mask 255.255.255.0. Option domain – name – the servers 192.168.43.2;

} Centos8 How to configure DHCP server

Default-lease-time reserves the IP address for a particular device for 10 minutes (600 seconds)

Max-lease-time retains the IP address for a maximum of 2 hours (7200 seconds).

The Subnet section defines the DHCP configuration for the 192.168.43.0/24 network.

The Range section defines assignable IP addresses ranging from 192.168.43.101 to 192.168.43.200.

The routers section defines the address of the default gateway.

The Subnet-Mask section defines the subnet mask that will be assigned to each host.

The domain-name-servers section defines the DNS server address that will be assigned to each host. After the configuration is complete, you can start the DHCP service with the following command:

[root@localhost ~]# systemctl enable dhcpd && systemctl start dhcpd Created symlink The/etc/systemd/system/multi – user. Target. Wants/DHCPD. Service to/usr/lib/systemd/system/DHCPD. Service. Centos8 Centos8 is a DHCP server and is running on a DHCP server

[root@localhost ~]# systemctl status DHCPD Centos8 How to configure a DHCP server

If a firewall is enabled, you need to enable the DHCP service in the firewall.

[root@localhost ~]# firewall-cmd –permanent –add-service=dhcp success [root@localhost ~]# firewall-cmd –reload Centos8 How to configure a DHCP server

192.168.43.254/192.168.43.254/192.168.43.254/192.168.43.254/192.168.43.254/192.168.43.254/192.168.43.254/192.168.43.254/192.168.43.254/192.168.43.254

[root@localhost ~]# nmcli connection show ens33 |grep -i ‘dhcp4.option[4]’ DHCP4.OPTION[4]: DHCP server identifier: 192.168.43.254 DHCP server identifier: 192.168.43.254

To set the reserved IP address, you need to know the network address of the server that needs to set the reserved IP address. Use the IP link to check the MAC address of the network card:

[root@localhost ~]# IP link Centos8: /etc/dhcp/dhcpd.conf The binding address is 192.168.43.150:

host server { hardware ethernet 00:0c:29:99:ee:d9; Fixed – address 192.168.43.150; } Centos8 DHCP server reboot DHCP server:

[root@localhost DHCP]# systemctl restart DHCPD [root@localhost DHCP]# systemctl restart DHCPD The DHCP server can see that the address has been retrieved.

In this tutorial, you learned how to configure a DHCP server on Centos8. We saw that the host automatically gets the IP address from the DHCP server, and we also saw how to bind an IP address to a specific computer using a MAC address.