Two BIND9 servers, one zone, and a need to keep them in lockstep so a primary outage does not take resolution down. This article walks the wiring: configure the primary to send NOTIFYs and allow transfers, configure the secondary to slave from the primary, sign the transfer with TSIG, and verify the topology with dig and the journal files. The deliverable is a redundant authoritative pair that survives a primary reboot without anyone noticing.
How to verify
Before declaring the topology healthy, confirm the secondary has the zone, the serial matches, and NOTIFYs are reaching it. The serial number is the truth — if it differs, you are looking at a transfer failure.
dig @primary.example.com example.com SOA +norec +short
dig @secondary.example.com example.com SOA +norec +short
sudo named-journalprint /var/cache/bind/example.com.db.jnl | head
sudo rndc zonestatus example.com
journalctl -u named -n 50 --no-pager | grep -E 'transfer|notify|refresh'
If the serials match, the zone is in sync. If the secondary shows an older serial, the next steps are: is the transfer ACL allowing the secondary? Is the TSIG key correct on both ends? Is port 53/TCP open between them?
What’s happening
A BIND primary holds the authoritative copy of a zone in a file under /etc/bind/zones/. A secondary holds a cached copy in /var/cache/bind/ that it pulled from the primary via an AXFR (full transfer) or IXFR (incremental transfer). The secondary refreshes on three triggers:
- NOTIFY — the primary sends an out-of-band message (“the zone changed”) to every NS listed in the zone, plus any servers in
also-notify. The secondary then issues a SOA query, compares the serial, and pulls if newer. - Refresh timer — the SOA record carries
refresh,retry,expire,minimum. Everyrefreshseconds the secondary checks the SOA and pulls if newer. NOTIFY is much faster, butrefreshis the fallback if NOTIFYs are lost. - Manual
rndc refresh example.com— the operator forces a check.
The transfer itself runs over TCP port 53 (DNS messages over 512 bytes use TCP, and a zone transfer is always TCP). TSIG signs the request and response so the secondary can prove it is talking to the right primary, and the primary can confirm the request came from an authorized peer. See IXFR vs AXFR for the differences in wire behavior.
The procedure
-
Generate a TSIG key shared by primary and secondary. Use
tsig-keygen(modern) instead of the deprecateddnssec-keygenfor TSIG:tsig-keygen -a hmac-sha256 transfer-example > /etc/bind/keys/transfer-example.key chmod 640 /etc/bind/keys/transfer-example.key chown root:bind /etc/bind/keys/transfer-example.keyCopy the file to the secondary (over an out-of-band channel — do not put the TSIG secret in a public repo). Reference it from
named.conf.localon both ends withinclude "/etc/bind/keys/transfer-example.key";. -
Configure the primary. In
named.conf.local, define the zone, restrict transfers to the secondary, and tell the primary which servers to NOTIFY:include "/etc/bind/keys/transfer-example.key"; server 203.0.113.20 { keys { "transfer-example"; }; }; zone "example.com" { type primary; file "/etc/bind/zones/db.example.com"; allow-transfer { key "transfer-example"; }; also-notify { 203.0.113.20; }; notify explicit; };notify explicitmeans “only notify the servers I list” — useful when the zone NS records publicly list servers you do not control (e.g. anycast nodes operated by a third party). -
Configure the secondary. Mirror the key, then declare the zone as
secondary:include "/etc/bind/keys/transfer-example.key"; server 203.0.113.10 { keys { "transfer-example"; }; }; zone "example.com" { type secondary; file "/var/cache/bind/db.example.com"; primaries { 203.0.113.10 key transfer-example; }; allow-notify { 203.0.113.10; }; allow-transfer { none; }; };allow-transfer { none; }on the secondary prevents downstream servers from chaining off it without explicit permission. -
Validate and reload both. Use
named-checkconf -zon each side. Then reload:sudo named-checkconf -z sudo systemctl reload named -
Force the first transfer. Bump the SOA serial on the primary (
example.comzone file,2026060201style), reload, and watch the secondary’s journal:sudo rndc reload example.com # on the primary sudo journalctl -u named -f # on the secondaryYou should see
transfer of 'example.com/IN' from 203.0.113.10#53: Transfer completedon the secondary within seconds of the primary reload. -
Confirm both serve the same data. Run the same
digquery against both and compare:dig @203.0.113.10 example.com AXFR -y hmac-sha256:transfer-example:KEY-SECRET-HERE for ns in 203.0.113.10 203.0.113.20; do echo "=== $ns ===" dig @$ns example.com SOA +short done
Common pitfalls
- Forgetting the firewall on TCP/53. Many UFW rulesets open UDP/53 and leave TCP/53 closed — transfers fail with a timeout that does not say “TCP is blocked,” it just hangs.
- Clock skew breaks TSIG. TSIG signs the request with a timestamp; if the two hosts differ by more than
fudgeseconds (default 300), the signature is rejected. Run chrony/ntpd on both. - NOTIFY sent but never received. The secondary’s
allow-notifymust include the primary’s IP. If the primary uses a different source IP for outbound (e.g. SNAT through a gateway), updateallow-notifyaccordingly. - AXFR on every notify. If the secondary keeps doing full AXFR instead of IXFR, the journal file is missing or stale — delete the
.jnland let it rebuild, or check that the primary hasixfr-from-differences yesfor primary-style zones. - Stale zone after
expire. If transfers fail for longer than theexpirevalue in the SOA, the secondary stops serving the zone and clients get SERVFAIL. Monitorexpiredistance to avoid silent outage.
In the engagements we run, the primary/secondary pair is rarely on its own — there is usually a hidden primary behind a published NS set, or a transfer chain feeding edge anycast nodes. The wiring is straightforward; the operational discipline is checking serials, watching NOTIFY latencies, and rotating the TSIG keys on a schedule. We do this routinely as part of how we operate clustered environments for clients.