DHCP server
Handing out addresses on a network — pool, reservations, leases, diagnostics.
Cheat sheet
3 commands Printable version-
sudo dhcpd -tcheck the config -
cat /var/lib/dhcp/dhcpd.leaseswho leased what -
journalctl -u isc-dhcp-serverDISCOVER/OFFER/ACK - dhcpd.conf: subnet/range/option routers/option domain-name-servers; host{} — a reservation
Overview
Configuration
/etc/dhcp/dhcpd.conf:
Set the interface in /etc/default/isc-dhcp-server (INTERFACESv4="eth0"),
then sudo systemctl restart isc-dhcp-server.
Recipes
1Troubleshooting
3Clients aren't getting an address
- Is the service listening on the right interface (
INTERFACESv4)? - Does the subnet in
dhcpd.confmatch 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
DHCPDISCOVERbut noDHCPOFFER→ no matchingsubnet/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.
Found an inaccuracy? Report an error in the article