Support Library
DNS Drift: Intended vs Live Records
If your DNS is defined somewhere, in a zone file, Terraform, DNSControl or a spreadsheet, the live records will sooner or later stop matching it. This guide covers where drift comes from, how to compare the two without drowning in false differences, and how to bring them back together without breaking anything.
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
| View | Where it comes from | What it can miss |
|---|---|---|
| Intended | A zone file in version control, Terraform or DNSControl code, an IPAM system or a change ticket | Records added by hand or by other systems |
| Provider | The provider's dashboard, API or zone export | Provider features that are not plain records, such as proxying, flattening or traffic policies |
| Live | Answers from the authoritative nameservers | Names 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.
| Difference | Normalize by |
|---|---|
| Name case and trailing dots | Lower-case every name and write it fully qualified, with the final dot |
| Relative names, @ and $ORIGIN | Expanding them to full names |
| IPv6 notation | Writing addresses in their compressed RFC 5952 form |
| TXT records split into several quoted strings | Joining the strings, since resolvers do so for SPF and DKIM |
| Record order | Sorting by name, type and data |
| TTLs | Comparing them separately, or leaving them out of the first pass |
| ALIAS, ANAME or flattened CNAMEs | Comparing 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.
| Step | Command |
|---|---|
| Canonicalize the intended file | named-compilezone -s full -o intended.txt example.com example.com.zone |
| Canonicalize the provider export | named-compilezone -s full -o live.txt example.com export.zone |
| Drop DNSSEC records and sort both | grep -v -E "\s(RRSIG|NSEC|NSEC3|DNSKEY)\s" live.txt | sort > live.sorted, and the same for intended.txt |
| Compare | diff -u intended.sorted live.sorted |
| Spot-check against the nameservers | dig +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"
| Difference | What it probably is | Decision |
|---|---|---|
| www points to 192.0.2.20 with a 300 second TTL | A server move done in the dashboard during an incident | Ask who changed it. If 192.0.2.20 is right, update the code, not the record. |
| old-shop exists in code but not live | Deleted by hand, still in code | Remove it from code, so a later apply does not recreate a CNAME to a service you have left |
| _acme-challenge TXT | A leftover certificate validation token | Safe 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
| Tool | Command | What it does |
|---|---|---|
| Terraform or OpenTofu | terraform plan -refresh-only | Shows how the provider's records differ from the last known state, without changing anything |
| DNSControl | dnscontrol preview | Lists the corrections it would make to bring each provider in line with dnsconfig.js |
| octoDNS | octodns-sync --config-file=config.yaml | Without --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
- Freeze writes to the zone while you reconcile, or at least tell the people who make changes.
- Classify each difference: adopt into the source of truth, revert live, or exclude because another system owns it.
- 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.
- Keep the export you took before reconciling. It is your rollback.
- 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.