Configure and Use DHCP Server

Configure DHCP ( Dynamic Host Configuration Protocol ) Server

[1] Install and configure DHCP Server. In this example it is configured for the [192.168.122.0/24] subnet.

[[email protected] ~]# dnf -y install dhcp

[[email protected] ~]# vi /etc/dhcp/dhcpd.conf
# specify domain name
option domain-name "futurelinux.org";

# specify DNS server's hostname or IP address
option domain-name-servers ns1.futurelinux.org;

# 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 192.168.122.0 netmask 255.255.255.0 {
    # specify the range of lease IP address
    range dynamic-bootp 192.168.122.100 192.168.122.200;
    # specify broadcast address
    option broadcast-address 192.168.122.254;
    # specify default gateway
    option routers 192.168.122.253;
}

[[email protected] ~]# systemctl start dhcpd
[[email protected] ~]# systemctl enable dhcpd
Created symlink /etc/systemd/system/multi-user.target.wants/dhcpd.service β†’ /usr/lib/systemd/system/dhcpd.service.

[2] If Firewalld is running, allow DHCP service. DHCP uses 67/UDP.

[[email protected] ~]# firewall-cmd --permanent --add-service=dhcp
success
[[email protected] ~]# firewall-cmd --reload
success

Configure DHCP Client. DHCP Client uses 68/UDP.

[1] For Future OS Clients, Configure like follows. (Replace the device name [ens3] to your own device name)

[[email protected] ~]# nmcli connection modify ens3 ipv4.method auto
[[email protected] ~]# nmcli connection down ens3
Connection 'ens3' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
[[email protected] ~]# nmcli connection up ens3
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)