[DNS Fundamentals Part 7] Running Authoritative DNS Servers: Zone Transfers, TTL Design, and Safe Change Procedures

DNS Fundamentals Part 7 Running Authoritative DNS Servers: Zone Transfers, TTL Design, and Safe Change Procedures DNS

“I fixed the zone on the primary, but the secondary is still serving the old data…”
“We’re moving a server next week. When should we switch the DNS?”

When you run authoritative DNS servers, changes are where accidents happen most often. And the scary part is that, because of caching, a DNS mistake cannot be undone right away.

Parts 5 and 6 covered the records you write in a zone. Part 7 covers how to operate the authoritative DNS servers that hold those records: redundancy with multiple servers, how zone transfers work, TTL design, and safe change procedures.

▶ This part is also available as a YouTube video (about 20 min) (it is also embedded at the end of this article).


Primary and secondary

If an authoritative DNS server stops, the names in that domain can no longer be resolved, so you run several of them.

Diagram showing an administrator editing the primary ns1, which transfers to the secondaries ns2 and ns3, while all three servers return the same answer with aa set to resolvers on the Internet
  • Primary: the server that holds the original zone data (a zone file or a database) and where changes are made
  • Secondary: a server that receives a copy of the zone from the primary

These used to be called “master/slave,” but the current terminology document, RFC 9499, uses primary/secondary, and BIND configuration is written type primary; and type secondary;.

Both return the same authoritative answer, and the party asking cannot tell them apart. List both in the NS records. You edit only the primary, and the secondaries end up with the same content through transfers.

Also note that an AD-integrated zone can be updated on any domain controller through AD replication, and managed DNS such as Route 53 hides the replication mechanism from its users.


Zone transfers: AXFR, IXFR, and NOTIFY

A secondary receiving a copy of the zone from the primary is called a zone transfer.

Diagram showing that when the administrator updates the zone with a higher serial, the primary sends NOTIFY, the secondary queries SOA and compares serials, then receives the difference by IXFR; and that an AXFR from an external host is refused
  1. When the zone is updated on the primary, it tells the secondaries about the change with NOTIFY (RFC 1996)
  2. A secondary that receives the notice queries the primary for the SOA
  3. If the serial number is higher than the one it holds, it requests a transfer

There are two kinds of transfer: AXFR (RFC 5936), which sends the whole zone, and IXFR (RFC 1995), which sends only the changes. Both use TCP. Even if the NOTIFY never arrives, a secondary checks on its own at the SOA REFRESH interval. So there are two ways to detect a change: NOTIFY (immediate) and REFRESH (periodic).

Do not allow zone transfers to anyone

If you allow zone transfers to anyone, they can retrieve the entire contents of the zone, hostnames included. This exposes your internal server layout from the outside, and it makes excellent reconnaissance material for an attacker.

Restrict transfers by the secondaries’ addresses and a TSIG key, and confirm that a transfer cannot be done from outside with dig AXFR (on Windows, ls -d in nslookup).

Key points
• NOTIFY announces the change, and the secondary transfers if the serial has increased
• AXFR for the whole zone, IXFR for differences. Both use TCP
• Allow transfers only to the secondaries. Try it from outside to confirm


How to number serials, and how to roll them back

The “I fixed the primary but the secondary is still old” at the start is almost always caused by this. A secondary transfers only when the serial has increased. If you forget to raise it, you get the classic accident where the primary is fixed but the secondary stays stale.

Check the serial on every server, one at a time.

$ dig @ns1.example.com example.com SOA +short
$ dig @ns2.example.com example.com SOA +short

PS> (Resolve-DnsName example.com -Type SOA -Server ns1.example.com).SerialNumber
  • Numbering: YYYYMMDDnn (the date plus a two-digit sequence number for that day, RFC 1912) is easy to read. It allows up to 100 changes per day. Some use tools that number automatically, or Unix time
  • A serial is a 32-bit number that wraps around, and what counts as “larger” is defined by the rules of RFC 1982. If you simply set it back to a smaller value, the secondary treats it as “older” and does not transfer

How to roll back a serial that was set too high by mistake

Suppose you mistyped the date, set the serial to 2026123101, and want to go back to 2026092502.

Diagram showing a two-step procedure: first set 4173606748, which is the wrong serial 2026123101 plus 2147483647, and confirm the transfer to every secondary; then set the desired value 2026092502 and confirm the transfer again
  1. Set it to 2026123101 + 2147483647 = 4173606748 (if the result exceeds 2^32, subtract 4294967296) → check with SOA that it was transferred to every secondary
  2. Set it to 2026092502 → again check the transfer to every secondary

If you manage all of the secondaries yourself, you can also use BIND’s rndc retransfer example.com, which transfers the zone again regardless of the serial. If you use an external secondary service, the two-step procedure above is the reliable one.


TSIG and XoT

These verify who you are transferring with and protect the contents.

# Create a shared key (the primary and the secondary hold the same key)
$ tsig-keygen -a hmac-sha256 xfr-key > /etc/bind/xfr-key.conf

# Primary named.conf (excerpt)
include "/etc/bind/xfr-key.conf";
zone "example.com" {
    type primary; file "example.com.zone";
    allow-transfer { key "xfr-key"; };
    also-notify { 198.51.100.53; };
};

# Secondary named.conf (excerpt. For XoT, add tls)
zone "example.com" {
    type secondary; file "example.com.zone";
    primaries { 192.0.2.53 key "xfr-key"; };
};
  • TSIG (RFC 8945): signs messages with a shared key to confirm that the other party is genuine and the message has not been tampered with for zone transfers, NOTIFY, and dynamic updates. It does not encrypt the content. It is more reliable than restricting by IP address alone
  • XoT (DNS Zone Transfer over TLS, RFC 9103, 2021): encrypts zone transfers with TLS (TCP/853). Use it when you do not want the zone contents read along the path. It can be combined with TSIG (for example, primaries { ... tls name; } in BIND 9.18 and later)

TTL design

TTL is a trade-off between “how fast changes take effect” and “how many queries you receive.” Keep a rule of thumb for each kind of record.

RecordTypical TTLThinking
NS, and A/AAAA of the NS hosts (glue)Around 86400 seconds (1 day)Rarely changed. Making it shorter only increases queries
Ordinary A/AAAA/CNAME3600 seconds (1 hour)A balance between how fast changes take effect and the query volume
Records you plan to switch, and failover done through DNS60 to 300 secondsShorten only what you need to take effect quickly
MX, TXT (SPF, DKIM, DMARC)Around 3600 secondsChanges can be planned
SOA MINIMUM (negative caching)300 to 3600 secondsThe upper limit on the “I added it but it won’t resolve” time
Route 53 alias (pointing to AWS resources)Cannot be specifiedThe target’s value is used (60 seconds for ELB)

A short TTL makes changes take effect quickly, but the cache is less effective, queries to the authoritative servers increase, and the impact of an authoritative outage shows up right away. The basic rule is “long normally, short only before a change.”

Also note that some resolvers set their own lower and upper limits on TTL, so records do not always expire exactly according to the TTL.


Change procedure: Lower the TTL before a migration

This is the most important part of Part 7. Let’s look at the procedure for changing the value of an A record, for example when moving a web server.

Timeline showing the TTL lowered from 86400 to 300 at T minus 2 days, old-TTL caches expiring at T minus 1 day, the value changed at T, most caches having the new value at T plus 5 minutes, the old server stopped at T plus 7 days, and the TTL restored afterward
WhenActionWhat to check
A few days before the workLower the TTL of the target record (for example, 86400 → 300)Every authoritative server returns the new TTL
Wait at least as long as the old TTLWait for the copies cached with the old TTL (for example, 1 day) to expireIf you switch without waiting, the old value can remain for up to the old TTL
Switchover dayChange the record’s value to the new IP addressOn every server: dig @ns1 ... +norec (Resolve-DnsName -NoRecursion -Server), and the SOA serial
Switchover + the new TTLMost caches now have the new valueTraffic to the new server rises and traffic to the old server falls
A few days to a weekLeave the old server runningA safeguard for clients and applications that ignore the TTL
Once things are stableRestore the TTL to its original valueIf you forget, query volume stays high

The key point is that by the time you change the value, the remaining life of the old IP in caches is already 5 minutes or less. That way, even if the switchover goes wrong, changing the value back restores things in about 5 minutes.

A common failure is changing the value right after lowering the TTL. Copies cached with a 1-day TTL before you lowered it can remain for up to 1 day afterward. Do not skip “wait at least as long as the old TTL.”

Two additional notes:

  • Do not query a new name before you create it. “Does not exist” stays in the negative cache (Part 3)
  • When you change NS to move to a different DNS provider, you cannot change the TTL of the NS records on the parent zone side yourself, so keep returning the same content from both old and new for a while (Part 12, Question 2)

Dynamic updates

Dynamic update (RFC 2136) is a mechanism for adding and deleting records with a message over the network, instead of editing the zone file by hand.

Diagram showing a Windows client, a DHCP server, and a domain controller updating an AD-integrated zone with GSS-TSIG, and a Linux administrator updating BIND with nsupdate and a TSIG key

AD is a familiar example.

  • A client registers its own A record
  • A domain controller registers SRV records
  • A DHCP server registers A and PTR records on behalf of the client (DHCP option 81)

For an AD-integrated zone, choose “Secure only” updates, which authenticate with GSS-TSIG (RFC 3645), using Kerberos. On Linux, use nsupdate with a TSIG key.

One caution: BIND records changes in a journal (.jnl), so you must not edit the zone file of a dynamically updated zone directly. To edit by hand, stop updates with rndc freeze, edit, and resume with rndc thaw. Stale records that linger are cleaned up by scavenging (Part 10).


Split horizon

Split horizon (split DNS) is a setup that returns different answers for the same name depending on who is asking. It is used, for example, to return an internal address for www.example.com to internal clients and the public address to outside clients, or to keep internal-only names from being visible externally.

acl "internal" { 203.0.113.0/24; };
view "internal" {
    match-clients { internal; };
    zone "example.com" { type primary; file "internal/example.com.zone"; };
};
view "external" {
    match-clients { any; };
    recursion no;
    zone "example.com" { type primary; file "external/example.com.zone"; };
};
Diagram showing that a query from an internal PC gets the internal address from view internal, and a query from an Internet resolver gets the public address from view external

There are several ways to do it.

  • BIND view (the example above. Once you use views, every zone must be placed in one of the views)
  • Windows Server DNS policies
  • Separate servers for internal DNS and public DNS
  • Route 53 private hosted zones (Part 10)

The convenience comes at a cost: you maintain two zones, so it is easy to update only one of them. It can also be behind hard-to-diagnose failures such as “only fails from inside the company” or “differs only while on the VPN” (Part 11). Remember that which view answers is decided only by the source address of the query.


Hidden primary

A hidden primary is a setup in which the primary is not listed in the NS records and does not answer queries from the Internet.

Diagram showing a hidden primary in a protected internal network distributing zones over TSIG-protected transfers to ns1 at another of the company's sites and ns2 at a DNS provider, with only the secondaries listed in NS answering resolvers
  • The primary is responsible only for editing the zone and transferring it to the secondaries, and only the secondaries listed in NS answer queries from outside
  • Because the primary can sit where it cannot be seen from outside, it is harder to attack, and you can edit and sign the zone (DNSSEC, Part 9) in a safe place
  • For secondaries you can use servers at your own other sites, or a DNS provider’s secondary service that runs on anycast
  • In the configuration, limit the primary’s allow-transfer and NOTIFY destinations to the secondaries

Even if the primary goes down, the secondaries keep answering until the SOA EXPIRE, which gives you some room to recover in the meantime. But that is pointless if you do not notice it is down, so never skip monitoring.


Anycast

Anycast advertises the same IP address from several sites at the same time and delivers users to the closest site by routing.

Diagram showing three sites in London, Singapore, and Tokyo all advertising 198.51.100.0/24, and that when the Tokyo site withdraws its route, users in Tokyo reach the Singapore site without changing any configuration

It suits DNS well. The root servers have 13 names (12 operating organizations), and over 2,000 sites worldwide (2,045 as of September 25, 2026) run them using anycast. TLDs, DNS providers such as Route 53, and public resolvers such as 8.8.8.8 use the same approach.

  • A nearby site answers, so responses are fast
  • DDoS traffic is also spread across the sites
  • If one site goes down, routes switch and another site answers

The caution is that if a site keeps advertising its route while its DNS is unhealthy, users near it cannot resolve names. Tie DNS monitoring to route advertisement. You can find out which site answered with dig +nsid.


DNS products today

The state of the main DNS products (as of September 2026).

ProductRoleCurrent version (September 2026)Characteristics
BIND 9Authoritative and caching9.20 series (stable, until 2028). The 9.18 series reached end of support in June 2026. 9.22 is not yet releasedThe most widely used. Rich in features
Unbound / NSDCaching / authoritative onlyUnbound 1.26, NSD 4.15From NLnet Labs. Lightweight, strong at DNSSEC validation
Knot DNS / Knot ResolverAuthoritative / cachingKnot DNS 3.6, Knot Resolver 6.4From CZ.NIC. High performance, automated DNSSEC operation
PowerDNSAuthoritative, caching, load balancingAuthoritative 5.1, Recursor 5.4, dnsdist 2.1Manages zones through a database or API
Windows Server DNSAuthoritative and cachingWindows Server 2025AD-integrated zones. Supports DoH on the DNS server from June 2026
dnsmasq / CoreDNSSmall-scale caching and DHCP / Kubernetesdnsmasq 2.93, CoreDNS 1.14Routers and virtualization platforms / the Kubernetes standard
DDI products such as InfobloxIntegrated DNS, DHCP, and IP address management—Centralized management through a GUI and API. Used in large internal networks

The versions were checked on each developer’s official site. Versions shipped in Linux distributions often keep an older version number while incorporating fixes, so judge by the distributor’s support period.


Choosing, and separating authoritative from caching

UseExample choicesWhat to look at
Authoritative DNS for public zonesManaged DNS such as Route 53; NSD, Knot DNS, or BIND plus a secondary serviceAvailability (anycast), DNSSEC, management through API and IaC
Internal caching DNSUnbound, BIND, Windows Server DNSDNSSEC validation, forwarding, logging and filtering
Internal DNS in an AD environmentWindows Server DNS (AD-integrated zones)Integrated operation with AD, secure dynamic updates
Large internal networksDDI products such as InfobloxIntegration with DHCP and IP address management, separation of privileges
Containers and small-scaleCoreDNS, dnsmasqMatch the platform’s standard

And there is a principle to follow whatever the product: do not combine authoritative and caching on the same server.

Diagram showing that combining authoritative and caching makes an open resolver likely, keeps answering from a stale zone after a domain moves, and spreads attacks and load, while separating them lets the authoritative server answer anyone and the caching server accept queries only from inside

There are three reasons.

  1. The access controls are opposites: an authoritative server answers queries from anyone, while a caching server accepts queries only from inside. Combine them and you easily end up with an open resolver (Part 9)
  2. Stale data remains: even after you move the domain to another provider, a combined server keeps answering internally from the old zone it still holds
  3. Failures and attacks spread: an attack or load on the cache (such as a random subdomain attack) can stop authoritative answers too, and the reverse can happen. It also makes it hard to plan updates and downtime for each role

The second reason is especially troublesome, causing failures like “the new site is visible from outside, but only the old site is visible from inside.”


Think about it

  1. How many authoritative DNS servers does your domain have, and where are they? Are they concentrated in the same data center or with the same provider?
  2. A job to move a web server to another cloud has been scheduled for two weeks from now. What will you do about DNS, and when? Draft a work plan following the timeline in “Change procedure” in this article.
  3. Check whether your internal DNS servers combine authoritative (internal zones) and caching. If they do, compare the benefits and the effort of separating them.

Hint: dig example.com NS +short and dig @each-server example.com SOA +short let you check the number of servers, where they are, and whether the serials match. Part 8 shows an example of listing the serial of every NS in PowerShell.


Summary

  • Authoritative DNS means a primary plus secondaries, several servers. List all of them in NS
  • A secondary transfers only when the serial has increased. Watch out for forgetting to raise it and for how to roll it back
  • Allow zone transfers only to the secondaries, and protect them with TSIG
  • TTL: “long normally, short only before a change.” Wait at least as long as the old TTL before changing the value
  • Do not edit a dynamically updated zone directly (freeze → edit → thaw)
  • With split horizon, watch out for missed updates. Keep authoritative and caching separate

Next time, we use what we have learned so far to see how to actually investigate DNS with dig and PowerShell commands.


Watch the video

This part is also explained in a YouTube video (about 20 min).

All parts of the series are in the DNS Fundamentals playlist on YouTube.

The DNS Fundamentals series (12 parts)

All 12 parts with a reading guide: DNS Fundamentals

  1. What Is DNS? How Name Resolution Works and Its Three Key Players
  2. The domain name hierarchy and delegation
  3. How name resolution works
  4. DNS messages and transport
  5. Resource records, part 1
  6. Resource records, part 2
  7. Running authoritative DNS servers (this article)
  8. Investigating with commands
  9. DNS security
  10. DNS in the cloud and on corporate networks
  11. DNS troubleshooting
  12. DNS design exercises

This series is the English edition of 【DNS入門】, originally written in Japanese.

コメント

Copied title and URL