22.6. Redundant DNS and DHCP Services
Everything built so far has one of each service. This section doubles the pieces that matter - resolvers, authoritative answers, and DHCP - and then rehearses the failure of each.
22.6.1. Authoritative Secondary Servers and Resolver Redundancy
The DNS side is already redundant from Sections 22.3.4 and 22.2.4: ns2 serves the zones by transfer, and both resolvers answer clients. What remains is reading the design as one picture:
- Clients hold two resolver addresses - in the DHCP options of Section 22.5.2 and in any static client's configuration - and try the second when the first fails.
- The resolvers hold two upstreams for the local zones: the
forward zone of Section 22.2.3 lists ns1, and the design
recommendation is to add ns2's
192.168.232.11beside it, so the forward-zone path survives a primary outage. The single-address form shown keeps every capture's query path unambiguous; the one-line change costs nothing and halves the failure modes. - The authoritative pair is itself redundant: NOTIFY pushes changes to ns2 in seconds, the SOA refresh timer is the fallback, and the expire timer bounds how long ns2 will keep serving without contact (14 days in the zone files).
The drill from Section 22.2.4 - stop unbound on resolver, verify
.54 still answers, restart - is the resolvers' half. The
authoritative half is the same shape: stop bind9 on ns1, and every
client's queries continue through ns2's transferred copies.
Recovery needs no manual resynchronization; the next NOTIFY or
refresh brings ns2 current, exactly as Section 22.3.4 showed after
rndc reload.
22.6.2. Kea High-Availability Peers, Lease Synchronization, and Failure Modes
Kea's HA hook keeps two servers' lease databases synchronized and assigns them complementary roles. Two modes matter:
| Mode | Who answers clients | Lease database flow | Best fit |
|---|---|---|---|
| hot-standby | the primary only; the standby serves nothing while the primary is healthy | primary replicates every lease to the standby; on failover the standby's copy is already complete | a site that wants simple, predictable behavior - this chapter's choice |
| load-balancing | both peers answer, splitting clients by hash | both replicate to each other continuously | a site that wants both servers working and can accept the extra moving parts |
Hot-standby is the simpler mental model - one answering server, one synchronized spare - and the one this section builds. The peer relationship rides an HTTP channel between the two servers, used for heartbeats and for lease synchronization; nothing about it depends on DNS.
Figure 22.5. The hot-standby state machine: one active server, one mirroring peer, and the transitions between them. The labels match the log messages the drills below capture.
The standby's configuration is the primary's with two values
changed: it names itself ns2 in this-server-name, and its DDNS
sender binds 192.168.232.11. On ns2 - as root - install the same
Kea packages, write /etc/kea/kea-dhcp4.conf as the Section 22.5.1
listing with those two substitutions, and start the service. The
HA stanza both hosts carry is the one already in that listing;
its fields are the whole mechanism, read once from ns1's side:
mode: hot-standby- the one-active-one-spare model of the table above.heartbeat-delay: 1000- a heartbeat every second over the peers' HTTP channel.max-response-delay: 5000- a partner that misses five seconds of contact is declared down. Together withmax-ack-delayandmax-unacked-clientsthese are the failover thresholds.peers- the two servers, each with a name matching itsthis-server-name, the URL of its HA channel (port 8000, peer to peer), and its role.auto-failover: truelets the standby promote itself without an administrator's command.
Both peers must also carry the lease-command hook (the
libdhcp_lease_cmds.so line already in the same listing)
because synchronization is implemented as lease commands over
that channel. Once both services run, the standby's database
should already hold the primary's leases. Verify through the
control socket. The check needs socat to connect the shell to
the socket, and it is not installed by default - as root on ns2:
# apt install socat
Then ask for every lease the standby holds - still as root on ns2:
# printf '{"command":"lease4-get-all","service":["dhcp4"]}' | socat - UNIX-CONNECT:/run/kea/kea4-ctrl-socket
{ "arguments": { "leases": [ { "cltt": 1795346112, "fqdn-fwd": true, "fqdn-rev": true, "hostname": "lanclient.handbook.test", "hw-address": "52:54:00:64:7a:37", "ip-address": "192.168.232.100", "state": 0, "subnet-id": 1, "valid-lft": 600 }, { "cltt": 1795346137, "fqdn-fwd": true, "fqdn-rev": true, "hostname": "printer.handbook.test", "hw-address": "52:54:00:22:00:01", "ip-address": "192.168.232.120", "state": 0, "subnet-id": 1, "valid-lft": 600 }, { "cltt": 1795346148, "fqdn-fwd": true, "fqdn-rev": true, "hostname": "relayclient.handbook.test", "hw-address": "52:54:00:55:af:68", "ip-address": "192.168.233.100", "state": 0, "subnet-id": 2, "valid-lft": 600 } ] }, "result": 0, "text": "3 IPv4 lease(s) found." }
The control socket speaks JSON: printf supplies the command, and
socat connects the pipe to the socket - the same query pattern
works for every command the hooks add. The answer lists all three
leases from the earlier sections - lanclient's, the printer
reservation's, and the relayed client's - synchronized onto ns2
with hostnames and DDNS flags intact. The standby knows everything
the primary knows.
Now fail the primary. Stopping the DHCP service on ns1 costs nothing in this network - leases persist on clients, and the standby is synchronized - but the same command on a production primary is the moment clients start noticing, so treat it as the drill's deliberate step. In a root shell on ns1:
# systemctl stop kea-dhcp4-server
Silent. The standby notices within its heartbeat window; read the transition from its log - in a root shell on ns2:
# grep HA_STATE_TRANSITION /var/log/kea/kea-dhcp4.log | tail -3
2026-11-22 11:13:16 INFO HA_STATE_TRANSITION ns2: server transitions from SYNCING to READY state, partner state is READY
2026-11-22 11:13:18 INFO HA_STATE_TRANSITION ns2: server transitions from READY to HOT-STANDBY state, partner state is HOT-STANDBY
2026-11-22 11:16:29 INFO HA_STATE_TRANSITION ns2: server transitions from HOT-STANDBY to PARTNER-DOWN state, partner state is UNDEFINED
Three lines, and each is a state from Figure 22.5: the startup
synchronization (SYNCING to READY), the entry into normal
operation (READY to HOT-STANDBY, both peers healthy), and -
seconds after the primary stopped, the heartbeat thresholds doing
their job - PARTNER-DOWN, partner state is UNDEFINED: ns1
missed too many heartbeats, and ns2 promoted itself to answering
server.
Prove it with a client that has never leased before. Give lanclient a fresh identity and ask - root shell for the link, john for the lease:
# ip link add link eth1 name mv2 address 52:54:00:22:00:06 type macvlan mode bridge
# ip link set mv2 up
Both commands print nothing. Now the lease - on lanclient, as john:
$ sudo dhclient -1 -v mv2
Internet Systems Consortium DHCP Client 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/mv2/52:54:00:22:00:06
Sending on LPF/mv2/52:54:00:22:00:06
Sending on Socket/fallback
DHCPDISCOVER on mv2 to 255.255.255.255 port 67 interval 3
DHCPOFFER of 192.168.232.101 from 192.168.232.11
DHCPREQUEST for 192.168.232.101 on mv2 to 255.255.255.255 port 67
DHCPACK of 192.168.232.101 from 192.168.232.11
bound to 192.168.232.101 -- renewal in 265 seconds.
from 192.168.232.11 - the standby answered alone, from the same
pool, with the same options, while the primary's service was
down. A new client's first lease is the strictest test of
failover, because it has no cached address, lease, or name to
survive on.
Recovery reverses the drill - in a root shell on ns1:
# systemctl start kea-dhcp4-server
Silent; ns1 returns, contacts ns2, and pulls the leases granted while it was away. The synchronization is visible in the returning server's log - as root on ns1:
# grep -E "HA_SYNC_SUCCESSFUL|HA_LEASES_SYNC_APPLIED" /var/log/kea/kea-dhcp4.log | tail -3
2026-11-22 11:13:16 INFO HA_SYNC_SUCCESSFUL ns1: lease database synchronization with ns2 (http://192.168.232.11:8000/) completed successfully in 2.403 ms
2026-11-22 11:16:49 INFO HA_LEASES_SYNC_APPLIED_LEASES ns1: applied 1 leases received from the partner in the local lease database
2026-11-22 11:16:49 INFO HA_SYNC_SUCCESSFUL ns1: lease database synchronization with ns2 (http://192.168.232.11:8000/) completed successfully in 2.560 ms
applied 1 leases received from the partner - exactly the lease
ns2 granted during the outage, replicated back. Both peers return
to hot-standby, and the returning primary takes over answering.
Remove the drill's link in lanclient's root shell with
ip link del mv2.
The failure modes the drill did not exercise deserve words,
because they are the ones that bite in production. Never stop both
peers at once - with no server answering, every new client is
offline; the HA hook cannot help with a failure it is part of. A
network partition that leaves both peers up but unable to reach
each other, while clients can reach both, is the dangerous case:
with auto-failover, both peers can decide the other is down and
start answering, handing out from databases that then diverge -
duplicate assignments with no detection. The mitigations are
structural: run the peer channel on a path clients do not use (a
direct link or dedicated VLAN), and prefer a standby that fails
closed - refusing to promote when its own network view is
degraded - over aggressive auto-failover. Finally, the HA hook
synchronizes leases, not the parent zone or any other service;
each redundancy in this chapter is separate machinery, and
Section 22.6.4 rehearses them as separate drills.
22.6.3. Authenticated Dynamic DNS Updates and Lease-to-Record Lifecycles
The pieces of the update chain are already in place from earlier sections; this is where they connect. The path, end to end:
- The client sends its hostname in the lease exchange
(
dhclient's configuration on the practice clients sendshost-name = gethostname(), the standard setting). - Kea, with
ddns-send-updatesand thedhcp-ddnsblock from Section 22.5.1, turns each grant or release into a name change request to127.0.0.1:53001. - The
kea-dhcp-ddnsservice - configured in Section 22.5.1 with theddns-keyTSIG secret and the zones' authoritative server - signs each request with that key and sends it to ns1 as an RFC 2136 UPDATE. - BIND's
allow-update { key "ddns-key"; }from Section 22.3.4's zone declarations accepts only key-holding updates, applies them to the zone journal, and increments the serial.
Read the four steps as one design: the client is trusted for nothing but its own name, the server is trusted to report its own leases, the update service is trusted because it holds the key, and the zone trusts only the key. No step believes an address, and every hop is authenticated or local.
The forward and reverse records for the first client were already visible in Section 22.5.2; here they are as the chain's output:
$ dig @192.168.232.10 lanclient.handbook.test A +short
192.168.232.100
$ dig @192.168.232.10 -x 192.168.232.100 +short
lanclient.handbook.test.
The A record and the PTR record both exist because a lease
carrying the hostname lanclient was granted - no administrator
edited either zone. The same records have lease semantics: the
ddns-update-on-renew and conflict-resolution settings in the
server configuration keep the record bound to the client that
holds the address, and a release tears the record down. Watch the
whole lifecycle - on lanclient, as john, release the lease:
$ sudo dhclient -r eth1
Removed stale PID file
The lease was released and the update chain tears the records down within
seconds - but the printed line deserves one explanation, because it is
client bookkeeping, not the release itself. dhclient keeps one shared
process-ID file, /var/run/dhclient.pid, and every one-shot run - the
macvlan drills included - overwrites it. At this point the file names a
process from an earlier drill that no longer runs, so the release reports
the stale file and moves on; a leftover drill client that was still
running would have printed Killed old client process instead. Either
line precedes the same working release.
The release also took lanclient's address with it - the lease is the address - so read the removal from a host that still has one. On resolver, as john:
$ dig @192.168.232.10 lanclient.handbook.test A +short
Empty output: no A record remains. dig still succeeded as a
query; there is simply nothing to answer with, which is
authenticated nonexistence - the zone's NSEC records prove no
record exists rather than the resolver guessing. Now reacquire -
on lanclient, as john:
$ sudo dhclient -1 eth1
Silent on success (no -v this time). The address and the record
return together; the check from lanclient works again:
$ dig @192.168.232.10 lanclient.handbook.test A +short
192.168.232.100
Released, removed, reacquired, recreated - the name followed the lease through its entire lifecycle. This is the mechanism that makes a DHCP network fully usable by name without anyone editing zone files, and it is also the reason the chapter's zones are dynamic: the journal from Section 22.3.5 is this section's workload.
The same authenticated-update path serves administrators directly:
Section 22.4.2's DS publication and Section 22.4.3's chain-break
drill both used nsupdate batches signed with ddns-key - the
administrator and the update service are both just TSIG-bearing
clients of the same zone policy. Rotating the key means generating
a new one with tsig-keygen, installing it in
/etc/bind/keys.conf and both Kea DDNS configurations, and
restarting the services - the zone's allow-update policy names
the key, not the key's bytes, so the rotation is a distribution
exercise.
22.6.4. Testing Renewals, New Leases, DNS Answers, and Recovery During an Outage
The drills in this section, run as one sequence, are the chapter's outage rehearsal. What follows is the runbook form, referencing the evidence each step produced.
Before the outage, verify all three redundancies agree:
- Both peers hold the same leases - the
lease4-get-allcapture on ns2 in Section 22.6.2 is the check, and the two databases should differ by nothing. - Both resolvers answer validated - the
.53and.54captures in Section 22.2.4. - The authoritative pair answers - primary and secondary, as in Section 22.3.4.
During the outage, stop the primary DHCP service
(Section 22.6.2's systemctl stop), and read the failure in this
order:
- The standby's state transition, in its log -
PARTNER-DOWNwithin the heartbeat thresholds; that line is the only authoritative statement that failover happened. - A new client's first lease - the strictest test, since a new
client has nothing cached. The mv2 exchange in Section 22.6.2,
answered
from 192.168.232.11, is that proof. - DNS from the client position - the authoritative servers and resolvers are separate failure domains from DHCP, so queries should answer throughout; the Section 22.5.4 capture of a relayed client resolving its own name is the same class of check. If DNS fails during a DHCP-only outage, something in the placement plan couples them - a finding, not a comfort.
Renewals of existing leases ride the timers of Figure 22.3: a client past its renew time first tries the server that granted the lease (unicast, toward the address in its DHCP server-identifier option, now down), then falls back at the rebind timer to broadcast, which the answering standby serves. With the chapter's timers that is a 180-second worst case; with production lifetimes it is proportionally longer. The chapter's drill demonstrated new leases and state transitions rather than a mid-outage renewal, and the timer mechanism above is why the difference is small: rebind is the same broadcast a new client uses, answered by whatever server is up.
Recovery is Section 22.6.2's closing captures: start the
primary, confirm the returning peer synchronized the leases it
missed (HA_LEASES_SYNC_APPLIED naming a count), and confirm the
next new lease is answered by the primary again. Rehearse the same
sequence for the resolvers (Section 22.2.4's stop/verify/start)
and, quarterly or so, for the authoritative pair - every drill in
this chapter is safe to repeat, which is the property that makes
rehearsal cheap and the reason to practice before the real thing.