Sub topic 14
Adding a Secondary Server with Zone Transfers and TSIG
This chapter assumes that you understand BIND zone files, named.conf, DNS records, and basic firewall rules. You also need two BIND servers: a primary at 192.0.2.10 and a secondary at 192.0.2.11.
A secondary server keeps a read-only copy of a zone. The primary remains the source of truth. When the zone changes, the primary sends a DNS NOTIFY message. The secondary then checks the serial number in the SOA record and requests an update.
| Transfer | Purpose |
|---|---|
| AXFR | Copies the complete zone |
| IXFR | Copies only changes since a known serial |
| NOTIFY | Tells secondaries to check for changes |
Zone transfers use TCP port 53. NOTIFY normally uses UDP port 53. Permit these connections between the two servers, but do not allow arbitrary hosts to transfer your zone.
Authenticate transfers with TSIG
TSIG, or Transaction Signature, adds a shared secret to DNS messages. Both servers calculate a signature from the message and the secret. A server that does not know the secret cannot request an authenticated transfer.
Generate the key on a secure administration system, then install the resulting file on both servers with permissions that allow only BIND to read it.
sudo tsig-keygen -a hmac-sha256 transfer-key | sudo tee /etc/bind/transfer-key.conf
sudo chmod 640 /etc/bind/transfer-key.confThe generated file contains a key declaration. Do not publish it or place it in a world-readable configuration directory.
Configure the primary
Include the key and restrict transfers to the secondary. The also-notify setting sends an immediate update notice when the zone changes.
include "/etc/bind/transfer-key.conf";
zone "example.com" {
type primary;
file "/etc/bind/db.example.com";
allow-transfer { key transfer-key; };
also-notify { 192.0.2.11; };
};Whenever you edit the zone file, increase the SOA serial number. A secondary will not download a zone whose serial is not newer than its local copy.
Configure the secondary
Copy the same TSIG key to the secondary. Define the primary server and a writable cache location for the transferred zone.
include "/etc/bind/transfer-key.conf";
server 192.0.2.10 {
keys { transfer-key; };
};
zone "example.com" {
type secondary;
primaries { 192.0.2.10; };
file "/var/cache/bind/db.example.com";
};The secondary should not be edited by hand. BIND creates and updates its local file after a successful transfer.
Validate and reload both servers. Then inspect the secondary directly.
sudo named-checkconf
sudo named-checkzone example.com /etc/bind/db.example.com
sudo rndc reload
dig @192.0.2.11 www.example.com A +short
dig @192.0.2.11 example.com SOA +shortExercise
You increased the primary's SOA serial, but the secondary still returns the old address. What should you check first?
Show answer
Check that the serial increased, TCP port 53 is allowed between the servers, the TSIG key matches, and BIND logs show a successful NOTIFY or transfer.