Introduction
- DHCP or (Dynamic Host Configuration Protocol) is a networking protocol that is used to provide dynamic IP addresses to clients on a network.
- In Linux servers, the DHCP service allows for automatic and centralized management of IP addresses.
- It is most used in Private networks (best for LAN use cases). It provides IP addresses to the clients connected the network.
- It uses UDP π UDP:67 used by the server and UDP:68 for the client
The process of IP leasing
There are 4 steps:
- DHCP Discover (client to server)
- DHCP Offer (server to client)
- DHCP Request (client to server)
- DHCP ACK (server to client)
Setting up DHCP
First, we need to install the DHCP package,
yum -y install dhcp-*
After installation is complete, we can open the configuration file,
vi /etc/dhcp/dhcp.conf
We will be able to see the following contents,
Adding the following to the file,
# The subnet that will be used
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.50 192.168.1.60; # IP addresses range
option domain-name-servers 8.8.8.8; # DNS server address
option routers 192.168.1.2; # This is the default gateway
max-lease-time 7200; # The lease time in seconds
}
# Declaring the name for the reservation of IP as 'Client'
host Client {
hardware ethernet 00:0C:29:90:B0:97; # MAC of the host
fixed-address 192.168.1.55; # Providing this IP to the host
}
Starting and enabling the DHCP daemon,
systemctl start dhcpd
systemctl enable dhcpd
Adding DHCP to the firewall,
firewall-cmd --permanent --add-service=dhcp
success
firewall-cmd --reload
Finally, on the client end, we have to set the IPv4 settings to automatic,
We can confirm this from the Windows PC,
The above simple DHCP configuration in the Linux system was able to provide an IP address for the Windows client PC
π Troubleshooting if it still shows the previous IP address
Using ipconfig /release
on the Windows CMD,
Then renewing it using ipconfig /renew
Top comments (0)