DYNAMIC HOST CONFIGURATION PROTOCOL -DHCP

DHCP Prerequisite settings- Static IP Address for Server


Server name : Linux1.example.com
IP Address : 192.168.2.1
Default Gateway : 192.168.2.1
DNS Addresses: 192.168.2.1, 8.8.8.8
                                    

Install DHCP RPM package on Server CentOS 8/9


#yum install dhcp-server
                     
                                    

Edit DHCP configuration file


#mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bk
#cp /usr/share/doc/dhcp-server/dhcpd.conf.example
/etc/dhcp/dhcpd.conf

#vi /etc/dhcp/dhcpd.conf

# dhcpd.conf # # Sample configuration file for ISC dhcpd # # option definitions common to all supported networks...

option domain-name "example.com";

option domain-name-servers 192.168.2.1, 8.8.8.8;

default-lease-time 600;

max-lease-time 7200;

# Use this to enble / disable dynamic dns updates globally. #ddns-update-style none; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented.

authoritative;

# Use this to send dhcp log messages to a different log file # have to hack syslog.conf to complete the redirection).

log-facility local7;

log-facility local7; # No service will be given on this subnet, but declaring it helps # DHCP server to understand the network topology. #subnet 10.152.187.0 netmask 255.255.255.0 { #}

# This is a very basic subnet declaration.

subnet 192.168.2.0 netmask 255.255.255.0 {

range 192.168.2.101 192.168.2.120;

option routers 192.168.2.1; }

All remaining lines in this file will be commented using #

Start/Stop Service


#service dhcpd start
#chkconfig dhcpd on
#service dhcpd status

If firewall is running


                                    
#firewall-cmd –add-service=dhcp –permanent
Success
#firewall-cmd --reload
Success
      

View DHCP Lease database


#cat /var/lib/dhcpd/dhcpd.leases
      

Client side settings

On LAN PC choose ..Network Adapter settings –Obtain IP Address automatically option.

Windows Clients like Windows 7/8/10/11

By using commands you can release IP address assigned by DHCP Server and renew it using ipconfig command.


                                    
Run – cmd – [Run cmd prompt – Run as Administrator]
C:\>ipconfig /release
C:\>ipconfig /renew
C:\>ipconfig/all