Configure DHCP (Dynamic Host Configuration Protocol) Server to assign IP addresses to client hosts in the local network.
First, install the DHCP Server package and configure it. In this example, we'll focus on IPv4 configuration.
[root@dlp ~]# dnf -y install dhcp-server
[root@dlp ~]# vi /etc/dhcp/dhcpd.conf
Edit the DHCP configuration file (/etc/dhcp/dhcpd.conf) as follows:
# specify domain name
option domain-name "emc.world";
# specify DNS server's hostname or IP address
option domain-name-servers dlp.emc.world;
# default lease time
default-lease-time 600;
# max lease time
max-lease-time 7200;
# this DHCP server to be declared valid
authoritative;
# specify network address and subnet mask
subnet 10.0.0.0 netmask 255.255.255.0 {
# specify the range of lease IP address
range dynamic-bootp 10.0.0.200 10.0.0.254;
# specify broadcast address
option broadcast-address 10.0.0.255;
# specify gateway
option routers 10.0.0.1;
}
Enable and start the DHCP Server service.
[root@dlp ~]# systemctl enable --now dhcpd
If Firewalld is running, allow DHCP service. DHCP Server uses port 67/UDP.
[root@dlp ~]# firewall-cmd --add-service=dhcp
[root@dlp ~]# firewall-cmd --runtime-to-permanent
You can monitor leased IP addresses in the following file:
[root@dlp ~]# ll /var/lib/dhcpd
total 4
-rw-r--r--. 1 dhcpd dhcpd 0 Aug 10 05:14 dhcpd6.leases
-rw-r--r--. 1 dhcpd dhcpd 617 Jan 11 10:50 dhcpd.leases
-rw-r--r--. 1 dhcpd dhcpd 0 Aug 10 05:14 dhcpd.leases~
[root@dlp ~]# cat /var/lib/dhcpd/dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.4.2b1
# authoring-byte-order entry is generated, DO NOT DELETE
authoring-byte-order little-endian;
server-duid "\000\001\000\001)o\235\357RT\000\337\207\255";
lease 10.0.0.233 {
starts 2 2022/01/11 01:50:28;
ends 2 2022/01/11 02:00:28;
cltt 2 2022/01/11 01:50:28;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:f3:7b:12;
uid "\001\000\014)\363{\022";
set vendor-class-identifier = "MSFT 5.0";
client-hostname "RX-78";
}
# ...
# ...
This file contains information about leased IP addresses and their lease duration. Please note that this is just an example and actual lease entries may vary based on your DHCP configuration.