Rotating a BIND TSIG Key by Changing Its Secret Stops Every Zone Transfer to the Secondaries
Overview
A routine TSIG key rotation that edits the secret in place quietly stops zone transfers. Here is how to confirm it and rotate in a safe order.
At a glance
- Symptom
- Secondaries stop receiving zone changes while the primary looks healthy.
- Likely cause
- In BIND, the key statement defines the shared secret.
- Impact
- Secondaries serve stale data and, once SOA EXPIRE passes, stop being authoritative for the zone.
- Verification signal
- On each secondary, run rndc zonestatus example.com and the SOA query against both servers.
- Safe correction
- The aim is a period in which the primary accepts both keys, so that no secondary is ever without a working one.
- Rollback or recovery
- Every state change above is a configuration edit with a saved copy, so rollback means restoring that copy and running rndc reconfig.
Someone runs tsig-keygen, pastes the new secret into the key block the primary already uses, and reloads. A BIND key only matches a request carrying the same name, algorithm and secret. Every secondary still holding the old secret is now refused, and keeps its last copy of the zone until the SOA EXPIRE timer runs out. Rotate by adding a second key name, moving the secondaries over, and only then removing the first.
Symptom
Secondaries stop receiving zone changes while the primary looks healthy. Nothing fails at the moment of the change. The primary answers queries, named-checkconf passes and the reload succeeds. The symptom arrives later: a record you changed on the primary never appears on a secondary, and the secondary’s SOA serial stays behind.
Compare the two serials:
dig @192.0.2.10 example.com SOA +short
dig @192.0.2.20 example.com SOA +short
If the primary’s serial is higher and stays higher after a refresh interval, transfers are not completing. The secondary’s xfer-in log category and the primary’s xfer-out category are where the attempts are recorded.
Why it looks safe
The change feels like replacing a password, and nobody expects a password change to touch the zone data. The same edit is also easy to test badly. named-checkconf checks syntax, not semantics, so it cannot tell you that the secondary’s copy of the secret no longer agrees with the primary’s. A config that parses and a primary that answers queries say nothing about whether the secondaries can still transfer.
The order you edit the servers in does not rescue you either: update the secondary first and its signed requests fail against the primary’s old secret instead.
Root cause
In BIND, the key statement defines the shared secret. When its name appears in an address match list, such as allow-transfer, it verifies that incoming requests were signed with a key matching that name, algorithm and secret. A request signed with the old secret under the same name is therefore not a match.
The list then does what any access list does. A non-negated match allows access, and with no match access is denied. If the key was the only element, the secondary’s transfer request is denied, with no fallback to the old secret.
The secondary side has one more constraint. In a server block, keys names the key used to sign requests to that server, and only a single key per server is currently supported. A secondary cannot try the new key and then the old one. It signs with whichever one it is told to, so the primary has to accept both for as long as the secondaries are split between them.
Impact
Secondaries serve stale data and, once SOA EXPIRE passes, stop being authoritative for the zone. Each one keeps its last good copy at first, so the early sign is stale data rather than an outage.
Every change you make on the primary after the rotation (a new record, a changed address, a retired host) fails to reach the secondaries. Clients that happen to hit one see the old answer.
The deadline is the SOA EXPIRE value. RFC 1035 defines it as the upper limit on the time that can elapse before the zone is no longer authoritative. When it passes, a secondary that never managed a successful refresh stops treating the zone as authoritative, and a problem that began as stale data becomes missing service. How long that takes depends on your own SOA values, so read them before deciding how urgent this is.
How to confirm it
These checks only read. Start on the secondary and ask BIND what it believes about the zone:
rndc zonestatus example.com
The output includes the current serial and the scheduled refresh or expiry times. A serial that has not moved and an expiry time that is getting closer fit this failure. Then take the key file the secondary uses and ask the primary for the zone yourself. This runs a full transfer, so choose a quiet moment for a large zone:
dig @192.0.2.10 example.com AXFR -k /etc/named/xfer-old.key
A refused or failed transfer with the secondary’s key, while the primary answers ordinary queries, points at the key rather than the network. Last, print each server’s configuration with the secrets obscured, and confirm the key names and algorithms agree:
named-checkconf -px /etc/named.conf
The -x option replaces shared secrets with question marks, so you can paste the output into a ticket. It also means you cannot compare the secrets this way. Treat the failed dig as the test for that.
The shortcuts that make it worse
- Add the secondary’s IP address to
allow-transfer. It restores transfers at once, but an address entry matches on address alone, and any match grants access. The zone is then only as protected as the network path to that address, which is the situation described in restricting AXFR by source IP alone. - Open the list with
any. The default whenallow-transferis not set isnone. Opening it lets any host take the whole zone, as the open AXFR default on BIND9 secondaries shows. - Paste the old secret back and carry on. It repairs the outage and leaves the original problem: you still have a key you wanted to retire and no safe way to retire it.
Correction
The aim is a period in which the primary accepts both keys, so that no secondary is ever without a working one. You need write access to named.conf on every server, rndc access, and the old key file. The examples use documentation addresses and key names. Adjust the paths to your distribution.
- Save the current state. On every server, copy
named.confand any included key file, for examplecp -p /etc/named.conf /etc/named.conf.pre-rotation. Rollback: none needed, as it only copies. - Generate a key under a new name. Run
tsig-keygen -a hmac-sha256 xfer-2026-12 > /etc/named/xfer-2026-12.key. A fresh name means the old key’s definition is never altered. Keep the file readable only by the name server, as the documentation describes for included key files, and copy the same key to each secondary over a channel you already trust. - Teach the primary both keys. Add the new key statement and list both keys in the zone’s
allow-transfer:allow-transfer { key "xfer-2025-06"; key "xfer-2026-12"; };Run
named-checkconf /etc/named.confand thenrndc reconfig. Rollback: restore the savednamed.confand runrndc reconfigagain. - Prove the new key before using it. From a secondary, run
dig @192.0.2.10 example.com AXFR -k /etc/named/xfer-2026-12.key. Stop if it fails: nothing has changed on the secondaries yet. - Move one secondary. Add the same key statement there and point its
serverblock at it:server 192.0.2.10 { keys "xfer-2026-12"; };Check the file, run
rndc reconfig, thenrndc retransfer example.com. Rollback: put the old key name back in theserverblock. The primary still accepts it. - Move the rest, one at a time, repeating the proof after each.
- Retire the old key last. Once every secondary has completed a transfer with the new key, remove the old key from
allow-transferand delete itskeystatement. Runnamed-checkconfandrndc reconfig. Rollback: re-add them from the copy saved in step 1.
Following along? Tap a step’s number to tick it off.
Verification
On each secondary, run rndc zonestatus example.com and the SOA query against both servers. The serials should match, and after a change on the primary they should match again within a refresh cycle.
After step 7, repeat the dig ... AXFR against the primary from a host that still has the old key file. It should now be refused, which shows the old secret no longer opens the zone. Check the xfer-in and xfer-out log categories for completed transfers rather than repeated failures.
Rollback
Every state change above is a configuration edit with a saved copy, so rollback means restoring that copy and running rndc reconfig. Before step 7, the primary accepts both keys, so reverting a secondary to the old key name always works.
After step 7, a revert needs the old key statement back on the primary first. That is why the copies from step 1 and the old key file are kept until all secondaries are confirmed. Zone data is never edited, because a secondary’s copy always comes from the primary.
Avoiding a repeat by never editing a live key
- Treat a key name as immutable. Change the secret by creating a new name, and put the date or a counter in the name so the overlap is visible in the configuration.
- List both keys in
allow-transferbefore any secondary is touched, and remove the old one only after each secondary has transferred with the new one. - Test with
dig ... AXFR -kfrom the secondary’s own host. A successful query from your workstation proves nothing about the key the secondary holds. - Set an alert on the serial difference between primary and secondary that fires well inside your SOA EXPIRE value.
Apply the safer control
Before you change production
Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.
Fix commands and configuration
tsig-keygennamed-checkconfdig @192.0.2.10 example.com SOA +short
dig @192.0.2.20 example.com SOA +shortWhen to escalate
Validation and rollback are covered in the sections above.
Escalate
Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Found this useful? Follow KBY for more like it.

