Back to Learning Center
DNS & DNSSEC

How to Track DNS Record Changes Across Many Domains

7 min read·Updated November 2026·By CertNotify Team

To track DNS changes across many domains, save each domain's records to a file on a schedule and compare it with the previous snapshot using diff. Whatever diff prints was added, removed or changed. The script below takes the snapshot with curl and Google Public DNS's JSON API, so it needs no DNS tools installed, only curl and python3.

Take a snapshot

With one domain per line in domains.txt:

#!/bin/sh
# Usage: sh dns-snapshot.sh domains.txt > snapshot-new.txt
# Records each domain's NS, MX, TXT, A and AAAA answers from Google
# Public DNS, one per line and sorted, so two snapshots can be compared
# with diff. Needs curl and python3.
lookup() {
  curl -s "https://dns.google/resolve?name=$1&type=$2" |
    python3 -c 'import json, sys
for a in json.load(sys.stdin).get("Answer", []):
    print(a["type"], a["data"])'
}
while read -r host; do
  [ -z "$host" ] && continue
  for type in NS MX TXT A AAAA; do
    lookup "$host" "$type" | sed "s|^|$host $type |"
  done
done < "$1" | sort
sh dns-snapshot.sh domains.txt > snapshot-new.txt

Part of the output for certnotify.com on 30 November 2026:

certnotify.com MX 15 10 mx2.hostinger.com.
certnotify.com MX 15 5 mx1.hostinger.com.
certnotify.com NS 2 kellen.ns.cloudflare.com.
certnotify.com NS 2 magali.ns.cloudflare.com.
certnotify.com TXT 16 v=spf1 include:_spf.mail.hostinger.com include:_spf.reach.hostinger.com ~all

The number is the DNS record type code from the answer: 1 for A, 2 for NS, 5 for CNAME, 15 for MX and 16 for TXT (RFC 1035), and 28 for AAAA (RFC 3596). Keeping it shows when a name you asked about is answered through a CNAME. The lines are sorted, so the order of the answers does not show up as a change.

Compare two snapshots

diff snapshot-old.txt snapshot-new.txt

To show the output format, the SPF line was edited by hand in a copy of the snapshot. diff printed the old line after < and the new one after >, and exited with status 1:

8c8
< certnotify.com TXT 16 v=spf1 include:_spf.mail.hostinger.com include:_spf.reach.hostinger.com ~all
---
> certnotify.com TXT 16 v=spf1 include:_spf.example.net ~all

No output and exit status 0 means nothing changed, which is what a scheduled job should check.

Which changes matter

  • NS: the domain moved to a different DNS host. Expected during a migration; alarming at any other time, because whoever runs the nameservers controls every other record.
  • MX: mail is now delivered somewhere else.
  • TXT: SPF and site-verification records live here. A changed SPF record changes who may send mail as the domain.
  • A and AAAA: the site's addresses. For a site behind a CDN these can change without anyone editing them, so treat a changed address as information, and a changed NS or MX as a question to ask.

Limits of a snapshot

  • One resolver's view. This asks Google Public DNS only. While a change propagates, other resolvers can still hold the old answer for up to the record's TTL. The DNS propagation check compares several.
  • Only the names you list. A record on a subdomain is seen only if the subdomain is in domains.txt. DMARC lives at _dmarc. plus the domain, so list that name too to track it.
  • Someone has to run it daily, keep yesterday's file and read the diff.

Doing this for client domains

On paid plans, CertNotify takes this snapshot once a day for every monitored domain. It records the A, AAAA, MX, NS, TXT and CNAME records and the _dmarc TXT record, and alerts you when they change. On paid plans a change is reported at the next daily check, not within minutes. For managed service providers, see monitoring for MSPs; to check SPF, DKIM and DMARC themselves, see the email authentication audit.

Common questions

How can I tell if someone changed my DNS records?

Keep a dated snapshot of each domain's records and compare it with a fresh one. Any line diff prints is a record that was added, removed or changed between the two.

Why do my A records change when nobody touched them?

Sites behind a CDN or a managed load balancer can be answered with different addresses over time, chosen by the provider. Compare NS, MX and TXT first; they change only when someone edits them.

How often should DNS be checked?

Daily catches configuration drift, such as a changed MX or SPF record, the day after it happens. Resolvers cache answers for the record's TTL, so a change can take that long to appear anywhere.

References and further reading

The specifications and primary documentation this article is based on.

Read next

More guides on the same subject.

Get the diff without running the script

On paid plans, CertNotify checks DNS records daily for every monitored domain and alerts you when NS, MX, TXT or address records change.

Start 14-day Pro trial