AXFR and IXFR in DNS
Introduction
AXFR is the DNS Zone Transfer Protocol. In a primary/secondary setup, the secondary asks the primary for the entire zone, and the primary returns every record in a single AXFR response, so the secondary can replace its local copy wholesale.
IXFR is Incremental Zone Transfer. Where AXFR sends the whole zone at once, IXFR sends only the records that changed.
Background
AXFR and IXFR both hinge on the serial number in the SOA record. We won’t go into the SOA record itself here, but the serial is the zone’s version number: it is incremented on every change, and both ends use it to decide which version is newer and whether a transfer is needed.
In the capture above (TCP handshake packets omitted):
- Packets 1 and 2 are the NOTIFY message and its reply — the primary announces that the zone changed;
- Packets 3 and 4 are the SOA query and response — the secondary asks for the current serial;
- Packets 10 and 12 are the IXFR request and response — the secondary asks for the delta. AXFR follows the same flow, only the query type differs.
AXFR
The first capture is an AXFR query, the second an AXFR response. The query is straightforward; in the response, all records sit in the Answer Section, framed by an SOA record at each end — those two act as opening and closing parentheses, and everything between them belongs to the zone.
IXFR
The captures above show a minimal IXFR exchange. Besides a different query type, an IXFR request carries one extra record in the third section (the Authority Section): the SOA record as the secondary currently knows it. The primary uses that serial (highlighted in the capture) to work out which changes have to be sent.
The response carries four SOA records, again in the Answer Section. The first and last SOA mean the same as in AXFR — they are the brackets. The second SOA holds the old serial and is followed by the RRs to be deleted; the third SOA holds the new serial and is followed by the RRs to be added. The excerpt below is from RFC 1995: consecutive updates can be chained in order, or collapsed by arithmetic into a single delta.
Beyond the normal case, IXFR has a few edge cases:
- The delta is incomplete or has been lost — the primary falls back to sending everything, and the Answer Section looks exactly like AXFR (SOA, records…, SOA);
- The requested serial already equals the current one — a single SOA record is returned;
- The requested serial is older, but no RRs changed — two SOA records are returned (SOA, SOA);
- The requested serial is newer than the primary’s — an error case, and the primary responds with a full AXFR.
References
- RFC 1995 IXFR: https://www.rfc-editor.org/rfc/rfc1995.txt
- RFC 1995bis IXFR: https://tools.ietf.org/id/draft-ah-dnsext-rfc1995bis-ixfr-02.html
- RFC 5936 AXFR: https://www.rfc-editor.org/rfc/rfc5936.txt