Chapter 22. DNS and DHCP Services
Two services quietly decide whether a network feels automatic or hostile: the resolver that turns names into addresses, and the DHCP server that hands out addresses in the first place. This chapter runs both for real. A pair of validating recursive resolvers (Unbound) serve client lookups; a primary and secondary authoritative server (BIND) publish the network's own zones, sign them with DNSSEC, and accept authenticated updates; a Kea DHCP server manages IPv4 and IPv6 leases, relays reach a second subnet, and a hot-standby peer takes over when the primary fails. The last section turns the whole assembly around and looks at it from the outside: firewalls, packet captures, stale caches, exhausted pools, and backups.
The design throughout is deliberate role separation. Resolving and authoritative answering run on different hosts, because they fail, age, and scale differently. DHCP runs on the authoritative primary because lease-to-name updates tie the two together, but its high-availability peer is independent of the DNS secondary. Every trust that crosses a host boundary - zone transfers, dynamic updates, the HA heartbeat - is authenticated with a shared secret, never with network reachability alone.
The six Debian 13 machines and their addresses:
| Host | Role | Practice interfaces | Administration |
|---|---|---|---|
ns1 |
authoritative DNS primary; Kea DHCPv4/DHCPv6 primary; DDNS updater; router advertisement source | eth1 - 192.168.232.10/24, fd22:232::10/64 |
eth0 - management network, 192.168.121.0/24 |
ns2 |
authoritative DNS secondary; Kea HA standby; second Unbound resolver | eth1 - 192.168.232.11/24, plus the resolver alias 192.168.232.54/24 |
eth0 - management network |
resolver |
validating recursive Unbound resolver | eth1 - 192.168.232.53/24 |
eth0 - management network |
dhcprelay |
DHCP relay and IPv4 router to the remote LAN | eth1 - remote LAN, 192.168.233.2/24; eth2 - primary LAN, 192.168.232.12/24 |
eth0 - management network |
lanclient |
ordinary LAN client; takes DHCP on eth1 |
eth1 - address from Kea |
eth0 - management network |
relayclient |
client on the remote LAN; served through the relay | eth1 - address from Kea via the relay |
eth0 - management network |
Figure 22.1. Two isolated practice LANs joined by a router that also relays DHCP. The primary LAN carries the DNS and DHCP services; the remote LAN has no server of its own and reaches everything through dhcprelay. Every host keeps a management interface for SSH that no exercise traffic uses.
The management network is the same insurance Chapter 21
built: every disruptive step in this chapter touches only eth1 and
eth2, so a broken zone file or a mis-filtered port 53 cannot cost
administrative access. The interfaces and routes were configured with
the tools of Chapter 17; the relay's
forwarding follows Chapter 19; firewall exposure
is discussed with Chapter 18's vocabulary.
Commands entered in john's ordinary shell begin with $ and
commands entered in a root shell begin with #; the prompt marker is
not typed. Single elevated steps are written $ sudo command, which
asks for john's password the first time in a session (the password is
not echoed). Sustained server-side work opens a root shell with
$ sudo -i - the prompt changes, HOME becomes /root, and exit
leaves the shell. john holds administrative rights through the sudo
delegation of Chapter 5; if your site
delegates differently, adapt the elevated commands to its method.
Before each command block the text names the target host and the
shell it runs in.
Example files, zone drafts, and capture files live under a named workspace in john's home directory. Create it on every host the chapter works on - here, on ns1:
$ mkdir -p ~/debian-handbook/dns-dhcp
The command prints nothing on success. Where a step produces files,
the text says to make the workspace the working directory with
cd ~/debian-handbook/dns-dhcp.
The captures in this chapter come from Debian 13.5 with kernel
6.12.86+deb13-amd64. The sections install their packages as they
reach them; the inventory below is the complete set on ns1 once every
section has run. In a root shell on ns1:
# dpkg-query -W bind9 bind9-utils bind9-dnsutils kea-dhcp4-server kea-dhcp6-server kea-dhcp-ddns-server kea-common isc-dhcp-client radvd tcpdump
bind9 1:9.20.30-1~deb13u1
bind9-dnsutils 1:9.20.30-1~deb13u1
bind9-utils 1:9.20.30-1~deb13u1
isc-dhcp-client 4.4.3-P1-8
kea-common 2.6.3-1+deb13u1
kea-dhcp-ddns-server 2.6.3-1+deb13u1
kea-dhcp4-server 2.6.3-1+deb13u1
kea-dhcp6-server 2.6.3-1+deb13u1
radvd 1:2.20-1+b1
tcpdump 4.99.5-2
kea-common arrives as a dependency of the server packages and
carries the hook libraries Section 22.6 loads. isc-dhcp-client
ships with the base system and provides the dhclient used on the
client hosts. Check the kernel and release once:
# uname -r
6.12.86+deb13-amd64
# cat /etc/debian_version
13.5
Leave the root shell with exit. Two shared secrets appear
literally in this chapter's configuration listings, because the
practice network is disposable and the captures would otherwise be
unreproducible; every place one appears, the text also shows how to
generate a replacement. On any real network, generate your own keys
and never publish them.
In this section
- 22.1. Planning Name and Address Services
- 22.2. Running a Recursive DNS Resolver
- 22.3. Serving Authoritative DNS with BIND
- 22.4. Signing and Maintaining Authoritative DNS
- 22.5. Providing DHCP with Kea
- 22.6. Redundant DNS and DHCP Services
- 22.7. Planning IPv6 Address Services
- 22.8. Operating and Troubleshooting DNS and DHCP