22.3. Serving Authoritative DNS with BIND
The authoritative tier publishes the network's own zones: the forward zone, the reverse zones, and the parent that ties them together. BIND is the tool Debian ships for this, and again the alternatives deserve one table before the work:
| Criterion | BIND 9 | NSD | Knot DNS | PowerDNS Authoritative |
|---|---|---|---|---|
| Intended role | recursive, authoritative, or both - the general toolkit | authoritative only | authoritative only | authoritative with database backends |
| Dynamic updates (RFC 2136) | native, TSIG-authenticated | not supported | via a companion request handler | via an API, not the DNS protocol |
| DNSSEC operation | dnssec-policy signs and rolls keys automatically |
manual signing tools | automated, policy-driven | automated per domain |
| Zone storage | text files (or a database) | text files | text files | SQL backends or BIND-compatible files |
| Debian packaging | bind9, first-class |
nsd |
knot |
pdns-auth |
| Best fit | the general case, and specifically any zone that must accept authenticated updates | pure authoritative serving at scale | authoritative tiers wanting automated DNSSEC with fewer moving parts | sites that manage zones in a database |
The deciding feature here is RFC 2136 dynamic updates: the
lease-to-name chain of Section 22.6.3 pushes records into the zone
with TSIG-signed UPDATE messages, and BIND's allow-update policy is
the receiving end. That narrows the field to BIND for this chapter's
design; a tier that only serves static zones could equally well run
NSD.
22.3.1. Separating Authoritative Service from Recursive Resolution
On ns1, install the server and its utilities - as root:
# apt install bind9 bind9-utils bind9-dnsutils
bind9 is the server, bind9-utils carries the checking tools and
tsig-keygen, and bind9-dnsutils provides dig and nsupdate.
Debian's package splits configuration the same way this chapter
splits roles. The main file /etc/bind/named.conf contains only
includes:
# /etc/bind/named.conf (Debian's default, unchanged)
// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian for information about the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.root-hints";
Options belong in named.conf.options, zones in named.conf.local.
One Debian detail matters more than it looks: named runs as the
bind user, /etc/bind is not writable by that user, and a zone
that accepts dynamic updates must be writable - so Debian's
convention keeps writable zone files under /var/lib/bind. Every
zone this chapter serves is dynamic or signed, so they all live
there.
The authoritative-only stance is one options block. Replace
/etc/bind/named.conf.options on ns1:
# /etc/bind/named.conf.options - authoritative-only primary
options {
directory "/var/cache/bind";
listen-on { 127.0.0.1; 192.168.232.10; };
listen-on-v6 { none; };
recursion no;
allow-query { any; };
allow-transfer { key "transfer-key"; };
notify yes;
also-notify { 192.168.232.11; };
dnssec-validation no;
minimal-responses yes;
version "not disclosed";
};
Line by line, each expresses a decision from Section 22.1:
listen-onpins the server to loopback and its LAN address - the same explicit-interface discipline as Unbound's.recursion nois the role separation; Section 22.1.1 already watched this server REFUSE a recursive query.allow-query { any; }lets any client ask about these zones - the zones are public within the practice network even though recursion is not.allow-transfer { key "transfer-key"; }gates zone transfers on a TSIG key instead of an address list; the secondary in Section 22.3.4 presents that key.notify yesandalso-notifypush the secondary to fetch changes immediately instead of waiting for the SOA refresh timer.dnssec-validation nois correct here, not a shortcut: this server is not resolving anything, and validating is the resolver's job.minimal-responsestrims referral-sized answers, and theversionstring keepsdig +nsid-style probes from learning the build.
The two TSIG keys this chapter needs are one small file. Generate
your own with tsig-keygen - the output below shows the file with
the lab's published secrets so the captures stay reproducible; on
any real network, run tsig-keygen -a hmac-sha256 transfer-key and
tsig-keygen -a hmac-sha256 ddns-key and keep the results private.
Write /etc/bind/keys.conf on ns1:
# /etc/bind/keys.conf - TSIG keys shared with the secondary and the DDNS updater
key "transfer-key" {
algorithm hmac-sha256;
secret "Y2hhcHRlcjIyLXRyYW5zZmVyLWtleS0wMDAx";
};
key "ddns-key" {
algorithm hmac-sha256;
secret "Y2hhcHRlcjIyLWRkbnMta2V5LTAwMDEtYWJjZGVm";
};
transfer-key authenticates zone transfers to ns2;
ddns-key authenticates dynamic updates from the DHCP update
service. A TSIG key is a shared secret: both ends must hold the same
bytes, and anyone holding them can act as either end - which is why
each purpose gets its own key, and why a lab's published secrets
would be a disaster in production.
With options and keys in place, check the whole configuration - still as root on ns1:
# named-checkconf
named-checkconf parses /etc/bind/named.conf and everything it
includes; it prints nothing when the configuration is valid, and
exits nonzero with a line number when it is not. The chapter's
policy is to run it before every service restart, the same way
Section 22.2.1 used unbound-checkconf.
The daemon is controlled with rndc, whose subcommands recur
through the rest of the chapter:
| Subcommand | Description |
|---|---|
rndc reload [zone] |
reload configuration, or one zone's file |
rndc reconfig |
reload configuration including new zone declarations |
rndc zonestatus zone |
show a zone's serial, files, and signing state |
rndc freeze zone / rndc thaw zone |
stop dynamic updates so the file can be edited by hand, then resume |
rndc dnssec -status zone |
show the zone's DNSSEC keys and their rollover goals |
rndc dnssec -rollover -key id zone |
schedule an immediate rollover of one key |
Debian ships a local rndc.key, so every rndc command in this
chapter works as root on the server it names.
22.3.2. Forward Zones, SOA Records, Serial Numbers, and TTLs
The forward zone holds the network's own names. Write
/var/lib/bind/handbook.test.db on ns1:
$TTL 300
$ORIGIN handbook.test.
@ IN SOA ns1.handbook.test. hostmaster.handbook.test. (
2026112201 ; serial
3600 ; refresh
900 ; retry
1209600 ; expire
300 ; negative TTL
)
IN NS ns1.handbook.test.
IN NS ns2.handbook.test.
ns1 IN A 192.168.232.10
ns2 IN A 192.168.232.11
resolver IN A 192.168.232.53
dhcprelay IN A 192.168.232.12
www IN A 192.168.232.10
cache 30 IN A 192.168.232.10
The zone's default TTL is 300 seconds - a deliberate lab choice that makes every cache effect in Section 22.8 observable within minutes. The SOA record carries the zone's own parameters:
| Field | Meaning | Value here |
|---|---|---|
| MNAME | the primary's own name | ns1.handbook.test. |
| RNAME | the responsible person, as a mailbox (hostmaster@) |
hostmaster.handbook.test. |
| Serial | the zone's version number; secondaries only transfer upward | 2026112201 - date plus two-digit counter |
| Refresh | how often a secondary checks for a new serial | 3600 s |
| Retry | a failed refresh waits this long before retrying | 900 s |
| Expire | after this long without contact, a secondary stops serving the zone | 1209600 s (14 days) |
| Negative TTL | how long a cached nonexistence answer lives | 300 s |
The serial is the one field with an operational discipline: it must
increase on every edit, or secondaries will silently keep the old
zone. The YYYYMMDDnn scheme encodes the date and a daily counter -
bump the counter for same-day edits, roll it over on a new day. The
cache record demonstrates per-record override: its explicit 30
beats the zone default, and Section 22.8.3 relies on exactly that
when it changes one record and watches caches age it out.
Validate the zone file before loading it - as root on ns1:
# named-checkzone handbook.test /var/lib/bind/handbook.test.db
zone handbook.test/IN: loaded serial 2026112201
OK
named-checkzone parses the file against the zone name, checks
record syntax, and reports the serial it found. To see what it
catches, keep a deliberately broken copy in the workspace - as john:
$TTL 300
$ORIGIN handbook.test.
@ IN SOA ns1.handbook.test. hostmaster.handbook.test. (
2026112299 ; serial
3600 ; refresh
900 ; retry
1209600 ; expire
300 ; negative TTL
)
IN NS ns1.handbook.test.
IN NS ns2.handbook.test.
ns1 IN A 192.168.232.10
broken IN A 192.168.232.999
One address octet is impossible. Check it - as root:
# named-checkzone handbook.test /home/john/debian-handbook/dns-dhcp/handbook.test.bad.db
dns_rdata_fromtext: /home/john/debian-handbook/dns-dhcp/handbook.test.bad.db:13: near '192.168.232.999': bad dotted quad
zone handbook.test/IN: loading from master file /home/john/debian-handbook/dns-dhcp/handbook.test.bad.db failed: bad dotted quad
zone handbook.test/IN: not loaded due to errors.
The checker names the file, the line, the offending token, and
refuses the zone. That exact refusal is why the file never reaches
named: named-checkconf and named-checkzone exist so that a
syntax error is a terminal message instead of a silently unloaded
zone at 3 a.m. Delete the broken copy when the point is made -
rm ~/debian-handbook/dns-dhcp/handbook.test.bad.db.
22.3.3. Reverse Zones for IPv4 and IPv6
Reverse resolution asks a different question - what name owns this
address? - and the DNS tree answers it under the special domains
in-addr.arpa (IPv4) and ip6.arpa (IPv6), with the address bytes
reversed. The primary LAN's reverse zone, at
/var/lib/bind/232.168.192.in-addr.arpa.db on ns1:
$TTL 300
$ORIGIN 232.168.192.in-addr.arpa.
@ IN SOA ns1.handbook.test. hostmaster.handbook.test. (
2026112201 ; serial
3600 ; refresh
900 ; retry
1209600 ; expire
300 ; negative TTL
)
IN NS ns1.handbook.test.
IN NS ns2.handbook.test.
10 IN PTR ns1.handbook.test.
11 IN PTR ns2.handbook.test.
53 IN PTR resolver.handbook.test.
192.168.232.10 becomes the label 10 under
232.168.192.in-addr.arpa - the address octets reversed, because
DNS delegates from the least specific end. The relay network gets
its own zone at /var/lib/bind/233.168.192.in-addr.arpa.db, same
structure, with the label 2 pointing at dhcprelay.handbook.test.
for the relay's 192.168.233.2.
IPv6 works the same way but reverses nibbles - half-bytes -
because IPv6 addresses are hexadecimal. The lab's prefix
fd22:232::/64 expands to fd22:0232:0000:0000: for the first 64
bits, and the 16 hex digits reversed become
0.0.0.0.0.0.0.0.2.3.2.0.2.2.d.f.ip6.arpa. Write the zone at
/var/lib/bind/fd22-232.ip6.arpa.db on ns1:
$TTL 300
$ORIGIN 0.0.0.0.0.0.0.0.2.3.2.0.2.2.d.f.ip6.arpa.
@ IN SOA ns1.handbook.test. hostmaster.handbook.test. (
2026112201 ; serial
3600 ; refresh
900 ; retry
1209600 ; expire
300 ; negative TTL
)
IN NS ns1.handbook.test.
IN NS ns2.handbook.test.
0.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR ns1.handbook.test.
1.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR ns2.handbook.test.
3.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR resolver.handbook.test.
fd22:232::10 is the address fd22:0232:0000:0000:0000:0000:0000:0010,
whose last 16 nibbles reversed are the long first label; the zone's
$ORIGIN carries the reversed prefix so labels only need the host
half. The reverse query is worth one live check - on lanclient, as
john:
$ dig @192.168.232.10 -x fd22:232::53 +short
resolver.handbook.test.
dig -x built the whole reversed name from the address and the
authoritative primary answered with the PTR. One practical note on
ownership: reverse zones for public addresses belong to whoever
holds the address space (usually delegated by the provider, and
Section 22.3.4's transfer machinery applies to them like any other
zone), while reverse zones for RFC 1918 space like 192.168.0.0/16
can only ever be served internally - no public parent will delegate
them, so the resolvers or authoritative servers inside the network
answer them, as here.
22.3.4. Secondary Servers, Transfers, and TSIG Authentication
A secondary serves the same zones from its own copy, fetched by
zone transfer (AXFR) from a primary it is told to trust. Configure
the zones on ns1 first - replace /etc/bind/named.conf.local:
# /etc/bind/named.conf.local on ns1 - zone declarations, primary
include "/etc/bind/keys.conf";
dnssec-policy "lab" {
keys {
ksk lifetime unlimited algorithm ecdsap256sha256;
zsk lifetime 30d algorithm ecdsap256sha256;
};
};
zone "test" {
type primary;
file "/var/lib/bind/test.db";
allow-update { key "ddns-key"; };
dnssec-policy lab;
};
zone "handbook.test" {
type primary;
file "/var/lib/bind/handbook.test.db";
allow-update { key "ddns-key"; };
allow-transfer { key "transfer-key"; };
dnssec-policy lab;
};
zone "232.168.192.in-addr.arpa" {
type primary;
file "/var/lib/bind/232.168.192.in-addr.arpa.db";
allow-update { key "ddns-key"; };
allow-transfer { key "transfer-key"; };
dnssec-policy lab;
};
zone "233.168.192.in-addr.arpa" {
type primary;
file "/var/lib/bind/233.168.192.in-addr.arpa.db";
allow-update { key "ddns-key"; };
allow-transfer { key "transfer-key"; };
dnssec-policy lab;
};
zone "0.0.0.0.0.0.0.0.2.3.2.0.2.2.d.f.ip6.arpa" {
type primary;
file "/var/lib/bind/fd22-232.ip6.arpa.db";
allow-transfer { key "transfer-key"; };
dnssec-policy lab;
};
Each zone states three policies: it is a primary reading its file
from /var/lib/bind; dynamic updates must present the ddns-key
(this is the gate Section 22.6.3's updates pass through); and
transfers must present the transfer-key. The dnssec-policy
block is Section 22.4's subject - leave it in place; it takes
effect there. The test zone is the local parent zone that
delegates handbook.test; its file, at /var/lib/bind/test.db,
carries the delegation with its glue:
$TTL 3600
$ORIGIN test.
@ IN SOA ns1.test. hostmaster.test. (
2026112201 ; serial
3600 ; refresh
900 ; retry
1209600 ; expire
300 ; negative TTL
)
IN NS ns1.test.
ns1 IN A 192.168.232.10
handbook IN NS ns1.handbook.test.
handbook IN NS ns2.handbook.test.
ns1.handbook IN A 192.168.232.10
ns2.handbook IN A 192.168.232.11
Three records make the delegation work: the NS lines that name the
child's servers, and the glue A records that give their addresses.
A resolver following a query for www.handbook.test reaches this
zone, is handed ns1 and ns2.handbook.test with their addresses,
and continues to the child. This local test TLD is a lab construct
standing in for a registered domain's real parent - the mechanics
of delegation, glue, and (in the next section) the DS record are
identical in both settings.
With every file in place, fix ownership so named can write its
journals, validate once more, and start the service - as root on
ns1:
# chown bind:bind /var/lib/bind/*.db && named-checkconf && systemctl restart bind9
The compound command chains three steps: ownership, validation, and restart. Nothing prints - the ownership change and validation are silent, and the restart succeeded - which the next commands verify.
The secondary's configuration mirrors the primary's zones with
type secondary instead. On ns2, install the same
bind9/bind9-utils/bind9-dnsutils packages, copy
/etc/bind/keys.conf unchanged (both hosts must hold identical key
bytes), and write the secondary's options - the Section 22.3.1
file with ns2's own address in listen-on, transfers refused
(allow-transfer { none; }), and notify no; in place of the
primary's notify lines. Then replace
/etc/bind/named.conf.local:
# /etc/bind/named.conf.local on ns2 - zone declarations, secondary
include "/etc/bind/keys.conf";
zone "handbook.test" {
type secondary;
primaries { 192.168.232.10 key "transfer-key"; };
file "/var/lib/bind/handbook.test.db";
allow-notify { 192.168.232.10; };
};
zone "232.168.192.in-addr.arpa" {
type secondary;
primaries { 192.168.232.10 key "transfer-key"; };
file "/var/lib/bind/232.168.192.in-addr.arpa.db";
allow-notify { 192.168.232.10; };
};
zone "233.168.192.in-addr.arpa" {
type secondary;
primaries { 192.168.232.10 key "transfer-key"; };
file "/var/lib/bind/233.168.192.in-addr.arpa.db";
allow-notify { 192.168.232.10; };
};
zone "0.0.0.0.0.0.0.0.2.3.2.0.2.2.d.f.ip6.arpa" {
type secondary;
primaries { 192.168.232.10 key "transfer-key"; };
file "/var/lib/bind/fd22-232.ip6.arpa.db";
allow-notify { 192.168.232.10; };
};
The primaries line names the transfer source and the key it
must present: ns2 will not accept a zone transfer from an address
that does not sign the request with transfer-key's secret. After
named-checkconf and a restart on ns2, the transfers happen at
startup, and both servers should hold identical data. Verify from
the client - on lanclient, as john:
$ dig @192.168.232.11 www.handbook.test A +short
192.168.232.10
The secondary answered the same record as the primary in Section 22.1.1. The SOA proves the copies agree:
$ dig @192.168.232.11 handbook.test SOA +short
ns1.handbook.test. hostmaster.handbook.test. 2026112204 3600 900 1209600 300
The serial in the secondary's SOA is 2026112204 - not the
2026112201 written into the file. The higher number is the signed
view's serial, produced by the DNSSEC signing process of Section
22.4, and its presence here means the transfer carried the signed
zone: secondaries of a signed zone need no signing machinery of
their own, because they transfer already-signed data.
Watch the transfer policy refuse a stranger. From lanclient, ask for a full zone transfer without any key - as john:
$ dig @192.168.232.10 handbook.test AXFR
; <<>> DiG 9.20.30-1~deb13u1-Debian <<>> @192.168.232.10 handbook.test AXFR
; (1 server found)
;; global options: +cmd
; Transfer failed.
Transfer failed. is dig reporting the connection closed with no
records - the server dropped the unauthenticated request. Now make
the same request from ns1's root shell, presenting the key:
# dig @127.0.0.1 -y hmac-sha256:transfer-key:Y2hhcHRlcjIyLXRyYW5zZmVyLWtleS0wMDAx handbook.test AXFR +noall +answer | head -5
handbook.test. 300 IN SOA ns1.handbook.test. hostmaster.handbook.test. 2026112204 3600 900 1209600 300
handbook.test. 300 IN RRSIG NS 13 2 300 20261206081114 20261122101226 14632 handbook.test. M7ctLRURgh5ebULB4BX43ofNlWQ9Vd9+ySxQm1rqheRdC8D3NyklOIkp KboTIkrCJX+zy1e0LmSos/H8A+mHsA==
handbook.test. 300 IN RRSIG NSEC 13 2 300 20261206081114 20261122101226 14632 handbook.test. 3pnFAzD+e+FDJwjHyE+h6+/C0DWT7Oc0kiyEMi4XS+oK1wUBebzG5N/8 Tbda7FzwwVxZmfm0lkPHCvPPxwCgeg==
handbook.test. 300 IN NSEC cache.handbook.test. NS SOA RRSIG NSEC DNSKEY TYPE65534
handbook.test. 300 IN RRSIG SOA 13 2 300 20261206111226 20261122101226 14632 handbook.test. J3zTUbJ0mJ5q6RRTvcOVTrQDhdKGChPJ8mODpQndg02FyVfGB5NpPyGD jDEam0CWViE8CSnOrVPnngQr+oSD+Q==
The transfer opens with the SOA (every AXFR starts and ends with
it), then the signed apex: RRSIG records covering the NS and NSEC
record sets, the NSEC record itself - the "next name" pointer that
authenticated denial-of-existence walks - and the SOA's signature.
Farther down the stream, beyond the head -5, come the zone's
ordinary records and the DNSKEY set, all signed; the secondary
receiving this gets the fully signed view, which is why the previous
subsection's SOA capture on ns2 already carried the signed serial.
The -y form passes algorithm:keyname:secret on the command line,
which is fine for a lab and a shell-history hazard in production -
the same query can read the key from a file instead on hosts that
configure one.
After any primary change, the secondary catches up either by NOTIFY (immediately) or by refresh (on the SOA timer). To force a refresh check by hand - in a root shell on ns2:
# rndc reload handbook.test
zone refresh queued
rndc reload on a secondary does not read a file; it queues a
freshness check against the primary, which ends in a transfer only
if the primary's serial is higher. That is the safe semantics: no
serial change, no transfer.
22.3.5. Validating and Reloading Zone Changes
The everyday workflow for a zone edit is four steps, and the chapter's tools make each one a gate:
- Edit the file (or apply an update - see below), bumping the serial.
named-checkzone handbook.test /var/lib/bind/handbook.test.db- syntax and the serial's presence.rndc reload handbook.test- load the new serial without restarting the daemon.- Verify:
rndc zonestatus handbook.teston the primary for the serial, then a query against the secondary, which should catch up via NOTIFY within seconds.
rndc zonestatus is the before/after instrument - as root on ns1:
# rndc zonestatus handbook.test
name: handbook.test
type: primary
files: /var/lib/bind/handbook.test.db
serial: 2026112201
signed serial: 2026112204
nodes: 7
last loaded: Sun, 22 Nov 2026 11:12:21 GMT
secure: yes
inline signing: yes
key maintenance: automatic
next key event: Sun, 22 Nov 2026 13:17:22 GMT
next resign node: dhcprelay.handbook.test/NSEC
next resign time: Tue, 01 Dec 2026 04:30:16 GMT
dynamic: yes
frozen: no
reconfigurable via modzone: no
Most of this report is Section 22.4's subject - secure: yes and
inline signing: yes say the zone is being signed automatically,
and the next key event/next resign lines are the signing
schedule. Two lines matter for editing policy right now: dynamic:
yes says this zone accepts updates, and that changes how a
hand edit must be made. A dynamic zone is not a static file -
named keeps a journal (handbook.test.db.jnl) of updates applied
since the last load, and hand-editing the file while the journal is
live produces a zone that jumps backward the next time the journal
replays. The documented procedure for a hand edit on a dynamic
zone is rndc freeze handbook.test (updates pause, the journal is
written into the file), edit and bump the serial,
named-checkzone, then rndc thaw handbook.test to resume. The
alternative is to make changes the way everything else in this
chapter does - as signed dynamic updates through nsupdate, which
journal correctly and need no freeze; Section 22.6.3 shows the
lifecycle, and Section 22.4.3 uses the same mechanism on the parent
zone.