DHCP Client and Server Basics
IP and Routing Tools showed how to add an IP address by hand with ip address add — but on most networks, servers and devices get their address automatically instead. That process is managed by DHCP (Dynamic Host Configuration Protocol); its protocol-level exchange (discover-offer-request-acknowledge) is already covered in DHCP and Leases. This article isn't about the protocol itself — it covers how the DHCP client behaves on the Linux side, how to inspect lease information, and how to stand up a simple DHCP server when one is needed.
How the DHCP Client Works on Linux
On modern distributions, the DHCP request is usually sent not by a standalone dhclient program but by the network manager itself — NetworkManager or systemd-networkd — each of which has its own built-in DHCP client implementation. On older or minimal systems, ISC's standalone dhclient still shows up. Which source an interface got its IP from can be seen in the proto field of ip route show:
proto dhcp means this route was obtained via DHCP — the interface is dynamically configured, not static.
Checking the Current Lease State
Depending on which tool is in use, lease information lives in different places.
If systemd-networkd is in use:
● 2: enp0s3
Link File: /usr/lib/systemd/network/99-default.link
Network File: /run/systemd/network/10-netplan-enp0s3.network
Type: ether
State: routable (configured)
Address: 192.168.1.122 (DHCP4)
fe80::a00:27ff:fe4a:1c9e
Gateway: 192.168.1.1
DNS: 192.168.1.1
If NetworkManager is in use:
On older systems running ISC dhclient, the lease file is typically stored here:
lease {
interface "enp0s3";
fixed-address 192.168.1.122;
option subnet-mask 255.255.255.0;
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1,1.1.1.1;
renew 3 2026/07/29 06:00:00;
expire 3 2026/07/29 18:00:00;
}
The fields that matter:
fixed-address— the IP currently assigned to this interface;routers— the default gateway handed out by the DHCP server;domain-name-servers— the DNS servers distributed via DHCP (the next article, DNS Tools, covers how these values get used);renew/expire— when the lease needs to be renewed, and when it expires entirely. The client normally sends an automatic renewal request at the halfway point (renewtime); if the server doesn't respond, it keeps retrying until expiration, after which the address returns to the pool.
Note
The exact lease file path and format depend on the distribution and the client in use: /var/lib/dhcp/ on Ubuntu/Debian, /var/lib/dhclient/ in some implementations. To find the exact path: find /var/lib -iname '*.leases' 2>/dev/null.
Renewing or Releasing a Lease by Hand
With systemd-networkd:
With NetworkManager, reactivating the interface also renews the lease:
With standalone dhclient:
-r releases the current lease back to the server and drops it; the second command sends a fresh request. Running this on a remote server where the interface is the only connection path can lead to an IP change or a temporary disconnection.
Setting Up a Simple DHCP Server (isc-dhcp-server)
In most production environments, the DHCP server is handled by network hardware (a router or firewall) or a cloud provider, but on a lab or isolated internal network it may be necessary to configure a Linux server as the DHCP server itself. This example uses isc-dhcp-server from the Ubuntu/Debian family.
Danger
Running two DHCP servers on the same physical network at the same time creates a rogue DHCP server situation: clients may end up randomly getting an IP, gateway, or DNS server from the wrong one, causing connectivity problems across the whole network. Only bring up a new DHCP server on an isolated lab network, or with explicit coordination with the network administrator.
Note
ISC has declared the original isc-dhcp-server (the dhcpd daemon) end-of-life — it still ships on Ubuntu/Debian and is perfectly fine for a lab, but ISC's actively developed successor is Kea, which is the right choice for a new production DHCP deployment. The concepts here — pools, lease times, host reservations — carry over directly; only the configuration syntax differs.
Installation:
Specifying which interface the service should listen on (on Debian/Ubuntu):
The main configuration lives in /etc/dhcp/dhcpd.conf:
default-lease-time 600;
max-lease-time 7200;
subnet 10.20.0.0 netmask 255.255.255.0 {
range 10.20.0.100 10.20.0.200;
option routers 10.20.0.1;
option domain-name-servers 10.20.0.1, 1.1.1.1;
option broadcast-address 10.20.0.255;
}
What each part means:
default-lease-time/max-lease-time— the lease time applied when a client doesn't request a specific duration, and the longest lease permitted, in seconds;range— the block of IP addresses handed out to clients (the pool); this range must never overlap with the server's own static addresses;option routers— the default gateway distributed to clients;option domain-name-servers— the DNS servers distributed to clients.
Checking the configuration's syntax and starting the service:
sudo dhcpd -t -cf /etc/dhcp/dhcpd.conf
sudo systemctl enable --now isc-dhcp-server
sudo systemctl status isc-dhcp-server
dhcpd -t is a check mode that validates the configuration file without restarting the service; don't reload the service if it reports an error.
Watching Leases Handed Out by the Server
This file shows the server's side of the story — which MAC address got which IP, and until when — and is the first place to look when investigating IP conflicts on the network.
Assigning a Permanent IP to a Specific Device (Static Lease)
If a device — a printer or an internal service, for example — should always get the same IP, this can be done through host reservation on the DHCP server instead of static configuration on the network side:
This entry can sit inside or outside the subnet block in dhcpd.conf, depending on the implementation; when the device requests an address with that specific MAC, the server always hands out that exact IP — but this is still delivered via DHCP, meaning the device gets no IP at all if the server is down. For services that must always be reachable, such as a database server, static configuration on the interface itself is the recommended approach instead.
Practical Scenario: A Server Is Getting the Wrong IP Instead of Its Reservation
Problem: a newly installed server gets a random address from the pool on every reboot, even though it was reserved for 10.20.0.50.
Step 1 — check:
Step 2 — hypothesis: the server's MAC address doesn't match the value in the host block on the DHCP server, or the reservation was written in the wrong subnet block.
Step 3 — check on the DHCP server side (without changing anything yet):
ip link show enp0s8 | grep link/ether
sudo grep -A2 'host printer-1st-floor' /etc/dhcp/dhcpd.conf
sudo grep 10.20.0.50 /var/lib/dhcp/dhcpd.leases
Step 4 — one change: if the MAC address in dhcpd.conf is wrong, fix it, re-check the configuration, and reload the service:
Step 5 — confirm: without restarting the server, renew the lease from the client side to verify:
Step 6 — documentation: record the MAC address error and how it was fixed, for the next administrator.
Common Mistakes
Accidentally Running Two DHCP Servers on the Same Network
An isc-dhcp-server set up for testing can end up left running on an interface connected to the production network. Always confirm INTERFACESv4 (or the equivalent configuration) points only to the intended, isolated interface.
Interpreting Lease Expiration as "the Network Went Down"
An IP address changing is sometimes just a lease expiring and a new one being handed out, especially when renewal failed. Check the renew/expire times in the lease file before drawing any other conclusion.
Not Noticing the Pool Range Has Run Out
If the range is small and the number of devices on the network is large, a new device may simply fail to get an address. Compare the number of active leases in dhcpd.leases against the total size of the range.
Confusing a Static Lease with a Static IP at the Interface Level
A DHCP host reservation still depends on the DHCP server — if the server is down, the device gets no address at all. This isn't sufficient for servers that must always be available; those need static configuration on the interface itself.
Interview angle
A question that comes up often: "if two DHCP servers exist on the same segment, how would you even notice?" The giveaway is usually inconsistent behavior — some clients get correct settings, others get a gateway or DNS server that makes no sense for the network, and the pattern looks random because it depends on which server's offer each client happened to accept first. dhcpd.leases on the legitimate server, cross-checked against the actual MAC addresses on the network from ip neigh, is the fastest way to confirm a rogue server is the cause rather than a misconfiguration on one particular client.
Exercises
- Confirm your server is getting its IP via DHCP by checking for
proto dhcpinip route show, then find the current lease file or the output ofnetworkctl status/nmcli device showand explain every field in it. - On a test VM, manually release a lease (
dhclient -rornetworkctl renew) and confirm a new IP was assigned. - On an isolated lab network (a virtual host-only network, for example), install
isc-dhcp-server, write a configuration with a smallrange, connect another test VM to that network, and watch it get an address. - Repeat the practical scenario above: deliberately write a
hostblock with the wrong MAC address, find the problem through the checks shown, then fix it.
Verification criterion: for exercise 4, your fix must be confirmed by the client actually receiving 10.20.0.50 (or your equivalent reserved address) after a lease renewal — not merely by the configuration file looking correct.
References
- man7.org:
dhclient(8): https://man7.org/linux/man-pages/man8/dhclient.8.html - man7.org:
dhcpd(8): https://man7.org/linux/man-pages/man8/dhcpd.8.html - man7.org:
dhcpd.conf(5): https://man7.org/linux/man-pages/man5/dhcpd.conf.5.html - man7.org:
dhclient.leases(5): https://man7.org/linux/man-pages/man5/dhclient.leases.5.html - freedesktop.org:
networkctl(1): https://www.freedesktop.org/software/systemd/man/latest/networkctl.html - Ubuntu Server — Networking: DHCP: https://ubuntu.com/server/docs/network-configuration
- ISC Kea/DHCP documentation: https://www.isc.org/dhcp/