Install and configure a DHCP server to provide automatic IPv4 address assignment for a subnet, including lease ranges, DNS, and default gateway options. Validate service health, confirm interface binding, and inspect active lease records to verify end-to-end operation.
Your network requires automatic IP assignment for client devices. You are tasked with deploying a DHCP server, defining an IPv4 scope, setting DNS servers and a default gateway, and verifying that leases are being issued correctly.
Treat DHCP changes as infrastructure changes. Validate syntax and service state before allowing clients to rely on the new scope, and always confirm the server is listening on the correct interface and subnet.
# Debian/Ubuntu
sudo apt install isc-dhcp-server -y
# RHEL/Rocky/Alma
sudo dnf install dhcp-server -y
# Arch
sudo pacman -S dhcp
# Confirm the server binary exists (one example):
command -v dhcpd
DHCP is typically provided by the ISC DHCP daemon
(dhcpd) or a distro-packaged equivalent.
Installing the package places the configuration file on disk
and registers the systemd service unit.
sudo vim /etc/dhcp/dhcpd.conf
# or
sudo nano /etc/dhcp/dhcpd.conf
subnet 192.168.50.0 netmask 255.255.255.0 {
range 192.168.50.10 192.168.50.100;
option domain-name-servers 8.8.8.8, 1.1.1.1;
option routers 192.168.50.1;
default-lease-time 600;
max-lease-time 7200;
}
At minimum you need a subnet declaration and a lease range.
Most environments also include DNS and a default gateway
(routers).
# Debian/Ubuntu (isc-dhcp-server)
echo 'INTERFACESv4="eth0"' | sudo tee /etc/default/isc-dhcp-server > /dev/null
# RHEL-style (dhcpd)
echo 'DHCPDARGS=eth0' | sudo tee /etc/sysconfig/dhcpd > /dev/null
# Confirm the interface exists and has the expected subnet:
ip -br addr show eth0
Binding prevents accidental lease offers on unintended networks and avoids confusing multi-interface hosts. The exact binding file varies by distribution.
# Debian/Ubuntu
sudo systemctl enable --now isc-dhcp-server
# RHEL-style
sudo systemctl enable --now dhcpd
# Confirm it is listening on UDP/67:
sudo ss -lunp | grep -E ':67\b'
Enabling ensures DHCP starts after boot. Starting it immediately lets you validate configuration correctness and listening behavior before clients depend on it.
# Debian/Ubuntu
sudo systemctl status isc-dhcp-server
# RHEL-style
sudo systemctl status dhcpd
# Typical success indicators:
# Listening on LPF/eth0/.../192.168.50.0/24
# Sending on LPF/eth0/.../192.168.50.0/24
If the daemon fails to start, common causes are config syntax
errors, incorrect interface binding, or a subnet mismatch
between dhcpd.conf and the server’s own IP.
# Path varies by distro
sudo cat /var/lib/dhcp/dhcpd.leases
# or
sudo cat /var/lib/dhcpd/dhcpd.leases
lease 192.168.50.10 {
starts 5 2025/12/19 22:05:01;
ends 5 2025/12/19 22:15:01;
binding state active;
hardware ethernet 3c:52:82:19:aa:0f;
client-hostname "laptop-qa";
}
The leases file is the authoritative record of issued addresses, including timestamps and client identifiers. This is your fastest “proof” that DHCP is working end-to-end.
Most failures come from a syntax error in
/etc/dhcp/dhcpd.conf
or a subnet mismatch. Confirm the server interface IP is in
the same subnet you declared, then inspect logs with
journalctl -u dhcpd
(or journalctl -u isc-dhcp-server).
Confirm UDP/67 is listening and bound to the correct interface. Then verify the interface binding file is set correctly for your distro and the client is on the expected L2 network.
Restrict the daemon to a single interface and re-check the system has only the intended interface connected to client networks.
If this is a disposable lab host, stop the service and remove configuration and lease data created during the exercise.
# Stop/disable (choose the service name that applies)
sudo systemctl disable --now dhcpd
sudo systemctl disable --now isc-dhcp-server
# Remove config (and leases if desired)
sudo rm -f /etc/dhcp/dhcpd.conf
sudo rm -f /var/lib/dhcp/dhcpd.leases /var/lib/dhcpd/dhcpd.leases
The DHCP service is stopped and disabled, and the host no longer has an active scope configuration or lease records from this lab.
dhcpd: DHCP server daemon that issues IPv4
leases and options.
/etc/dhcp/dhcpd.conf: Main DHCP server config
file (subnets, ranges, options).
systemctl enable --now <service>: Enable a
service at boot and start it immediately.
--now: Start the unit immediately.ss -lunp: Show UDP listening sockets and the
owning process.
-l: Listening sockets only.-u: UDP sockets.-n: No name resolution.-p: Show process info.ip -br addr: Quick view of interface addresses
to confirm the server is on the expected subnet.
-br: Brief output format.journalctl -u <service>: View service logs
for startup, binding, and lease activity.
-u: Filter by unit name./var/lib/dhcp*/dhcpd.leases: Lease database used
to confirm active and historical leases.