The short answer

DNS drift is any difference between the records you intend to publish and the records your authoritative servers actually serve. It comes from dashboard edits, other tools and services writing records, and providers adding or rewriting records on their own. To find it, export or query the live records, normalize both sides into the same form, and diff them. Then decide, record by record, whether the live change should be adopted into your source of truth or reverted. Never let a tool "fix" drift by applying the old intent blindly: the live record may be the one that is right.

Three views of the same zone

ViewWhere it comes fromWhat it can miss
IntendedA zone file in version control, Terraform or DNSControl code, an IPAM system or a change ticketRecords added by hand or by other systems
ProviderThe provider's dashboard, API or zone exportProvider features that are not plain records, such as proxying, flattening or traffic policies
LiveAnswers from the authoritative nameserversNames you did not think to ask for, because most providers refuse zone transfers to the public

Drift between intended and provider is a process problem. Drift between provider and live, or between nameservers, is a serving problem, such as a secondary that has stopped receiving zone transfers.

Where drift comes from

  • Dashboard edits during an incident that never make it back into code.
  • More than one tool writing the same zone, for example Terraform for most records and a deployment script for a few.
  • Automation that owns some names: ACME clients writing _acme-challenge TXT records, Kubernetes ExternalDNS, or a cloud platform creating verification records.
  • Provider defaults: records added when a zone is created, TTLs rounded to values the provider supports, or proxied records that answer with the provider's own addresses.
  • Multi-provider setups where one provider's sync failed.
  • Expired intent: a record removed from code but never deleted, often a CNAME to a service you no longer use.

Normalize before you compare

The same record can be written many ways. Without normalizing, a diff is full of differences that do not matter.

DifferenceNormalize by
Name case and trailing dotsLower-case every name and write it fully qualified, with the final dot
Relative names, @ and $ORIGINExpanding them to full names
IPv6 notationWriting addresses in their compressed RFC 5952 form
TXT records split into several quoted stringsJoining the strings, since resolvers do so for SPF and DKIM
Record orderSorting by name, type and data
TTLsComparing them separately, or leaving them out of the first pass
ALIAS, ANAME or flattened CNAMEsComparing the configured target, since live answers show the resolved addresses
DNSSEC records (RRSIG, NSEC, DNSKEY)Leaving them out; they are generated by the signer

BIND's named-compilezone can rewrite a zone file into one canonical form, which takes care of most of this for files.

A worked comparison

Say the intended records for example.com live in example.com.zone in a repository, and the provider can export the live zone in the same format.

StepCommand
Canonicalize the intended filenamed-compilezone -s full -o intended.txt example.com example.com.zone
Canonicalize the provider exportnamed-compilezone -s full -o live.txt example.com export.zone
Drop DNSSEC records and sort bothgrep -v -E "\s(RRSIG|NSEC|NSEC3|DNSKEY)\s" live.txt | sort > live.sorted, and the same for intended.txt
Comparediff -u intended.sorted live.sorted
Spot-check against the nameserversdig +norecurse @ns1.example.com www.example.com A

The output might look like this:

--- intended.sorted
+++ live.sorted
-old-shop.example.com.   3600 IN CNAME shops.example.net.
-www.example.com.        3600 IN A     192.0.2.10
+www.example.com.        300  IN A     192.0.2.20
+_acme-challenge.example.com. 60 IN TXT "Q2hhbGxlbmdlVG9rZW4"
DifferenceWhat it probably isDecision
www points to 192.0.2.20 with a 300 second TTLA server move done in the dashboard during an incidentAsk who changed it. If 192.0.2.20 is right, update the code, not the record.
old-shop exists in code but not liveDeleted by hand, still in codeRemove it from code, so a later apply does not recreate a CNAME to a service you have left
_acme-challenge TXTA leftover certificate validation tokenSafe to delete once no issuance is in progress. Exclude the name from future diffs.

If the provider has no export, build the live view by querying a list of known names against an authoritative server, one type at a time. That only finds names you already know about, which is one reason to keep the intended view complete.

Tools that report drift

ToolCommandWhat it does
Terraform or OpenTofuterraform plan -refresh-onlyShows how the provider's records differ from the last known state, without changing anything
DNSControldnscontrol previewLists the corrections it would make to bring each provider in line with dnsconfig.js
octoDNSoctodns-sync --config-file=config.yamlWithout --doit, prints the plan only

Each of these reports drift only for the records and providers it manages, and some ignore record types they do not support. Run the preview on a schedule, for example in CI, and treat a non-empty plan as a question to answer, not a change to apply.

Reconciling and rolling back

  1. Freeze writes to the zone while you reconcile, or at least tell the people who make changes.
  2. Classify each difference: adopt into the source of truth, revert live, or exclude because another system owns it.
  3. Make the smallest change first. Update code to match live where live is right; revert live records one at a time where it is wrong.
  4. Keep the export you took before reconciling. It is your rollback.
  5. Prevent repeats: limit dashboard access, give automation its own subdomains or record ownership (ExternalDNS uses TXT ownership records for this), and add drift checks to the change process.

How DNS Panopticon helps

DNS Panopticon does not detect drift or compare your code with your zone. It can help with parts of the check: Zone Analyzer reads a provider export in your browser so you can review every record, including leftovers, and the DNS Propagation Checker can compare the live answers for one record with a value you expect, across the authoritative servers and public resolvers.

FAQ

Is drift always a mistake?

No. Often the live record is right and the code is out of date, for example after an emergency fix. The point of a drift check is to notice and decide, not to revert automatically.

Can I download a zone with AXFR to compare it?

Only from servers that allow you to. Most providers refuse public zone transfers, so use their export or API instead.

How often should I check for drift?

Daily is common for zones managed as code, plus before every planned change, so you are not about to overwrite something someone did by hand.

Why does my plan want to change records nobody touched?

Usually a normalization difference, such as a TTL the provider rounds, a TXT record split into several strings, or a record type the tool reads differently. Fix the code to match what the provider stores.

Sources and further reading