DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses, subnet masks, gateways and DNS servers to network clients. Without DHCP, every device would need manual IP configuration.
DHCP Server Profile
Package: dhcp
Daemon: dhcpd
Config file: /etc/dhcp/dhcpd.conf
Lease file: /var/lib/dhcpd/dhcpd.leases
Port: 67/UDP (server), 68/UDP (client)
Log: /var/log/messages
Configure DHCP Server
# Install:
# yum install dhcp -y
# Configure:
# vim /etc/dhcp/dhcpd.conf
# Global settings:
option domain-name "example.com";
option domain-name-servers 172.25.9.11;
default-lease-time 600; # 600 seconds (10 min)
max-lease-time 7200; # 7200 seconds (2 hrs)
# Subnet declaration:
subnet 172.25.9.0 netmask 255.255.255.0 {
range 172.25.9.50 172.25.9.100; # IP pool for clients
option routers 172.25.9.1; # default gateway
option subnet-mask 255.255.255.0;
option domain-name-servers 172.25.9.11;
option broadcast-address 172.25.9.255;
}
Assign Static IP by MAC Address
# Add inside /etc/dhcp/dhcpd.conf:
host client9 {
hardware ethernet 52:54:00:00:00:09; # client MAC address
fixed-address 172.25.9.10; # always assign this IP
}
Start DHCP Server
# RHEL 7:
# systemctl start dhcpd
# systemctl enable dhcpd
# RHEL 6:
# service dhcpd start
# chkconfig dhcpd on
# Firewall:
# firewall-cmd --permanent --add-service=dhcp
# firewall-cmd --reload
# RHEL 6 iptables:
# iptables -A INPUT -p udp --dport 67 -j ACCEPT
# service iptables save
Configure DHCP Client
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=dhcp
ONBOOT=yes
# Apply:
# systemctl restart NetworkManager # RHEL 7
# service network restart # RHEL 6
# Request IP now:
# dhclient eth0 # request DHCP lease
# dhclient -r eth0 # release lease
Monitor and Troubleshoot DHCP
# View active leases:
# cat /var/lib/dhcpd/dhcpd.leases
# Check DHCP log messages:
# grep dhcpd /var/log/messages
# Check DHCP server is running:
# systemctl status dhcpd
# ss -tulnp | grep dhcpd
# Common issues:
# "No subnet declaration for eth0" → subnet in dhcpd.conf doesn't match server's IP
# Client not getting IP → check firewall port 67/UDP
# Wrong gateway → check 'option routers' in dhcpd.conf