Loading...

Lab 105: Installing, Configuring, and Managing a DHCP Server

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.

networking services core

Scenario

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.

Operator context

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.

Objective

  • Install a DHCP server package on the system.
  • Configure an IPv4 subnet scope with a lease range, DNS servers, and default gateway.
  • Bind the DHCP service to the correct network interface.
  • Enable and start the service and confirm it is running.
  • Validate lease issuance by inspecting the leases database.

Concepts

  • DHCP roles: server offers leases and options; clients request configuration during boot or network changes.
  • Scope design: subnet definition, address range, and excluded addresses.
  • Core options: DNS servers, default gateway (router), and lease timers.
  • Interface binding: limiting where the daemon listens to avoid unintended lease offers.
  • Validation: confirming UDP/67 listening state and verifying leases on disk.

Walkthrough

Step 1 : Install the DHCP server package.
Commands
# 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.

Step 2 : Configure an IPv4 scope in the main config file.
Command
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).

Step 3 : Bind the DHCP service to the correct interface.
Commands
# 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.

Step 4 : Enable and start the DHCP service.
Commands
# 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.

Step 5 : Confirm healthy startup and correct subnet binding.
Commands
# 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.

Step 6 : Inspect the leases database to verify lease issuance.
Commands
# 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.

Common breakpoints

Service will not start

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).

No leases are being issued

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.

Wrong network gets offers

Restrict the daemon to a single interface and re-check the system has only the intended interface connected to client networks.

Cleanup checklist

If this is a disposable lab host, stop the service and remove configuration and lease data created during the exercise.

Commands
# 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
Success signal

The DHCP service is stopped and disabled, and the host no longer has an active scope configuration or lease records from this lab.

Reference

  • 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.