Where to start First steps track · 15 stages
Linux Labs

DHCP server

3 min Ubuntu 24.04 · isc-dhcp / kea

Handing out addresses on a network — pool, reservations, leases, diagnostics.

Cheat sheet

3 commands Printable version
  • sudo dhcpd -t check the config
  • cat /var/lib/dhcp/dhcpd.leases who leased what
  • journalctl -u isc-dhcp-server DISCOVER/OFFER/ACK
  • dhcpd.conf: subnet/range/option routers/option domain-name-servers; host{} — a reservation

Overview

A DHCP server automatically hands clients an IP address, gateway, DNS, and more. On Linux this is isc-dhcp-server (the classic) or kea (ISC's newer one). For the client side, see ip/netplan.

bash
systemctl status isc-dhcp-server
journalctl -u isc-dhcp-server -f  # watch DISCOVER/OFFER/REQUEST/ACK

Configuration

/etc/dhcp/dhcpd.conf:

default-lease-time 3600;
max-lease-time 86400;

subnet 10.0.0.0 netmask 255.255.255.0 {
    range 10.0.0.100 10.0.0.200;
    option routers 10.0.0.1;
    option domain-name-servers 1.1.1.1, 8.8.8.8;
}

# a fixed address by MAC (a reservation)
host printer {
    hardware ethernet aa:bb:cc:dd:ee:ff;
    fixed-address 10.0.0.50;
}

Set the interface in /etc/default/isc-dhcp-server (INTERFACESv4="eth0"), then sudo systemctl restart isc-dhcp-server.

Recipes

1

Leases and diagnostics

bash
cat /var/lib/dhcp/dhcpd.leases     # active leases (who got what)
sudo dhcpd -t                      # check the config syntax
journalctl -u isc-dhcp-server      # log of DHCP negotiations

Troubleshooting

3

Clients aren't getting an address

  • Is the service listening on the right interface (INTERFACESv4)?
  • Does the subnet in dhcpd.conf match the interface's subnet?
  • DHCP uses broadcast — nothing should block it between client and server (or you need a dhcp-relay on the router).
  • The log shows DHCPDISCOVER but no DHCPOFFER → no matching subnet/range.

Address conflict / two DHCP servers on the network

Two servers are handing out from overlapping pools. A network should have one authoritative DHCP server (or strictly separated pools).

A MAC reservation isn't taking effect

Check the exact MAC (hardware ethernet) and that the address is outside the dynamic range.

Terms

1
DHCP
A protocol for obtaining network configuration automatically from a server. Also appears in: hostnamectl, cloud-init, ip, Persistent networking with netplan and 1 more

See also

  • ip — Managing interfaces, addresses, and routes (iproute2) — the replacement for ifconfig/route.
  • dns-resolv — How a name becomes an IP — resolv.conf, systemd-resolved, /etc/hosts, dig.
  • firewall — Traffic filtering — simple ufw and low-level nftables.
Loading…