← First Pair Library

10 Zone transfer and secondary service

10.1 AXFR is a stream, not a giant datagram

AXFR transfers a complete zone over TCP. A successful stream begins with the zone’s SOA, contains the zone records, and ends with the SOA again. The records may span many DNS messages. A client must continue until it sees the closing SOA under the transfer rules; reading one response is insufficient.

Transfers reveal the zone contents and can consume resources, so authorities normally restrict clients. TSIG is a common authentication mechanism in the wider ecosystem, while IP allowlists are a simpler policy with weaker identity properties.

src/axfr.rs provides both sides. axfrdns accepts TCP only and checks client networks, loopback by default. It requires one AXFR question, obtains a boundary-aware transfer from Zone, and frames bounded messages. Zone::transfer excludes records beneath delegated child zones and wraps the result in the apex SOA.

axfr-get generates a random transaction ID, validates response identity and shape, collects records until the closing SOA, renders them in tinydns source form, writes a temporary output, and atomically installs the completed file. The temporary/final path pair prevents a failed transfer from replacing usable data with a partial zone.