How to Monitor DNS Changes and What to Do When Your Records Change Unexpectedly

How to Monitor DNS Changes and What to Do When Your Records Change Unexpectedly

Your website files can be perfectly clean and your domain can still send visitors somewhere else. DNS, the system that translates your domain name into the IP address of the server that answers for it, lives at your registrar and DNS host, outside the server you back up and scan. Change one A record and every visitor goes wherever the new value points, with nothing on your server touched. In this post we’ll look at what to baseline, how to catch an unexpected change, and what to do in the hours after you find one.

Contents:

Why unexpected DNS changes matter

Unexpected DNS changes can redirect visitors, disrupt email, and expose your domain to abuse without affecting your website’s files. Because DNS is managed separately from your web server, traditional malware scans may not detect the problem.

One of the most common risks is traffic redirection. If an attacker changes your domain’s A record, visitors could be sent to a phishing page, malicious download, or fraudulent website. Your actual website may remain completely untouched, making the issue harder to identify.

Email interception is another concern. Unauthorized changes to MX records can redirect incoming messages to servers controlled by an attacker, potentially exposing sensitive communications and password reset links.

Attackers can also create or redirect subdomains to host phishing pages that appear connected to your business. These activities can damage your domain’s reputation and trigger security warnings or blocklisting.

Finally, DNS manipulation can affect certificate security. An attacker who gains sufficient control over your DNS may be able to obtain a valid TLS certificate for your domain, making a fraudulent website appear more trustworthy to visitors.

These risks make DNS monitoring an important part of website security, even when your server and website files show no signs of compromise.

What to baseline

A baseline is just a saved, dated copy of the correct answers for every name and record type you use, stored somewhere outside the DNS panel itself. Without it you have no way to say whether today’s value is wrong, only whether it looks unfamiliar.

Start with the apex domain and www, then add every subdomain you actually use: mail, shop, staging, api, CDN hostnames, anything your marketing tools asked you to create.

RecordWhat it doesWhat a malicious change looks like
A / AAAAPoints a hostname at an IPv4 or IPv6 addressAn IP you don’t recognize, or a hosting provider you’ve never used; sometimes only on a subdomain so the homepage looks normal
CNAMEAliases one hostname to anotherwww or a subdomain aliased to a third-party host; a CNAME added where an A record used to be
NSDelegates the zone to nameserversNameservers you didn’t set, which hands the whole zone over at once; the most damaging single edit
MXSays which servers accept your emailAn unfamiliar mail host, or a new MX with a lower priority number so it wins over yours
TXTHolds SPF, DKIM, DMARC, and provider verification stringsA rewritten SPF record that authorizes someone else’s sender, a weakened DMARC policy, or a new verification string that lets an outsider claim your domain in a third-party service
CAALimits which certificate authorities may issue for your domainThe record removed, or an extra CA added
TTL valuesHow long resolvers cache each answerA TTL raised sharply before a change, so the bad answer sticks in caches longer

Baseline your registrar account too, as it’s a layer above the records. Capture the nameservers listed on the domain, the contact email address, the transfer lock status, and the expiry date. Save all of it as a plain text file in version control or a password manager note, with the date you captured it.

How to monitor DNS changes

There are four layers here, and they catch different things. Pick at least the first two.

A manual check with dig or nslookup. On macOS or Linux, dig +short A yourdomain.com returns the current answer from your resolver. Swap in the type you want:

  • dig +short MX yourdomain.com
  • dig +short NS yourdomain.com
  • dig +short TXT yourdomain.com

On Windows, nslookup -type=mx yourdomain.com does the equivalent. Query more than one resolver, because a change can be live at some resolvers while others still serve a cached answer: dig @1.1.1.1 +short A yourdomain.com and dig @8.8.8.8 +short A yourdomain.com.

To skip caching entirely, look up your nameservers first and then ask one of them directly: dig @ns1.example-dns.com +short A yourdomain.com.

A scripted diff on a cron job. This is the part most vendor roundups skip, and it’s maybe fifteen lines. The script collects the same records every time, sorts them so output order doesn’t create false alerts, and compares against your saved baseline:

#!/bin/sh
NAMES="yourdomain.com www.yourdomain.com mail.yourdomain.com"
TYPES="A AAAA CNAME MX NS TXT CAA"
DIR="/var/lib/dns-watch"

mkdir -p "$DIR"
: > "$DIR/current.txt"
for name in $NAMES; do
  for type in $TYPES; do
    echo "== $name $type" >> "$DIR/current.txt"
    dig +short "$type" "$name" | sort >> "$DIR/current.txt"
  done
done

if [ ! -f "$DIR/baseline.txt" ]; then
  cp "$DIR/current.txt" "$DIR/baseline.txt"
  exit 0
fi

if ! diff -u "$DIR/baseline.txt" "$DIR/current.txt" > "$DIR/diff.txt"; then
  mail -s "DNS change detected: yourdomain.com" you@example.org < "$DIR/diff.txt"
fi

Save it as /usr/local/bin/dns-watch.sh, make it executable, and run it hourly from cron with 0 * * * * /usr/local/bin/dns-watch.sh. The first run writes the baseline; every run after that emails you the diff when something moves. After a planned change, review the diff, then copy current.txt over baseline.txt so the next alert means something again. Run it from a machine that isn’t the web server, and send the alert to an address that doesn’t depend on your domain’s MX records. Otherwise an MX hijack takes out your own alerting.

Turn on the notifications your provider and registrar already offer. Most registrars and managed DNS services can email you whenever a record is edited, an API token is used, or a transfer is requested. Many also keep an audit log showing which account made each change. They give you the one thing a diff can’t: who did it, and from where.

Watch the certificate transparency logs. Publicly trusted certificates get recorded in public logs, so a certificate issued for a hostname on your domain shows up in a searchable record. Subscribe to a CT monitoring service for your domain and you’ll hear about an unexpected certificate (often a sign that someone has already proved DNS control) even if the record they used has since been removed.

DNS monitoring sits alongside the checks you already run on the server. File integrity monitoring compares your files against a known state and will tell you if something changed on disk; see What is File Integrity Monitoring (FIM)? for how that side works. Uptime and availability checking covers whether visitors can reach you at all, which we cover in What is Website Monitoring?.

Warning signs your DNS has been tampered with

Unauthorized DNS changes aren’t always immediately obvious. Your website may appear normal while visitors in other locations experience redirects, email delivery problems, or security warnings.

Common warning signs include:

  • Unexpected redirects: Visitors report unfamiliar pages or suspicious redirects, even though your website appears normal when you check it.
  • Email delivery issues: Messages stop arriving, or senders receive bounce notifications referencing mail servers you don’t recognize.
  • Email authentication failures: SPF or DMARC checks begin failing unexpectedly, potentially indicating changes to your TXT records.
  • Unknown subdomains: Certificate transparency alerts, search results, or abuse reports reference subdomains you didn’t create.
  • Security warnings: Your domain or a subdomain appears on a blocklist or triggers malware warnings, but website scans reveal no issues.
  • Unfamiliar nameservers: The nameservers listed at your registrar no longer match those configured for your DNS provider.

If you notice any of these signs, compare your current DNS records against your saved baseline and review recent changes in your registrar or DNS provider’s audit logs. Catching unauthorized changes early can help limit their impact.

What to do when a record changes unexpectedly

Work through these in order. The first step matters more than it sounds, because a surprising share of “unexplained” changes are a colleague or an agency doing legitimate work.

  1. Confirm the change is real and unauthorized. Re-query the record from a second resolver and from your authoritative nameserver, then check the audit log in your DNS panel and registrar account for who made the edit and when.
  2. Capture evidence before you fix anything. Save the dig output and the diff your script sent. Add the audit log entries and screenshots of what visitors are seeing. You’ll want timestamps later.
  3. Revert the record to the baseline value. If delegation was changed, correct the nameservers at the registrar first, since nothing you do inside the old DNS panel will reach visitors until that’s back.
  4. Shorten the TTL on records you just corrected so any further fix propagates faster. Expect a delay while caches holding the bad answer expire; you can’t flush resolvers you don’t operate.
  5. Rotate all credentials at the registrar and the DNS provider. Do the same for any reseller or hosting panel account with DNS access, being sure to remove users and tokens you can’t account for.
  6. Enable two-factor authentication on both accounts and switch the registrar’s transfer lock back on if it was disabled.
  7. Deal with email if MX or SPF records were touched. Reset passwords for accounts whose reset emails could have been intercepted, and tell affected staff that mail from the window may have been read.
  8. Review certificates. Search certificate transparency logs for your domain, ask the issuing CA to revoke anything you didn’t request, and publish a CAA record naming the CAs you actually use.
  9. Check the website itself. DNS access and server access sometimes come from the same compromised credential set. Run a full scan and compare files against a known-good copy. How to Run a Security Test and Set Up Continuous Monitoring walks through that side of the check.
  10. Save the corrected records as your new baseline file, with the date.

If customer data or email contents were exposed, your notification obligations depend on where your customers are. Have that conversation early with whoever handles it for you.

Preventing DNS tampering

Protecting your DNS starts with securing the accounts that control it. Enable two-factor authentication, use strong passwords, and limit access to authorized users. Keep your domain’s transfer lock enabled, and consider a registry lock for additional protection.

Regularly review your DNS records and remove outdated entries, particularly CNAME records pointing to services you no longer use. Consider enabling DNSSEC to protect against forged DNS responses, although it won’t prevent unauthorized changes to your DNS settings.

Ongoing monitoring is equally important. Sucuri’s website security platform includes DNS monitoring to detect unexpected record changes, alongside SSL monitoring, malware scanning, and website security alerts. These tools help you identify suspicious activity and investigate potential compromises before they cause further damage.

Ultimately, keeping your DNS secure requires both strong access controls and consistent monitoring. With the right protections and visibility in place, you can catch unexpected changes early and respond before they put your website or visitors at risk.


Frequently asked questions

How often should I check my DNS records?

Automate it. An hourly scripted diff catches most tampering before a bad answer spreads widely through resolver caches, and daily is reasonable for a small site. Check manually after any planned edit, migration, or registrar change, then save the new values as your baseline so the next alert means something.

How do I know if my DNS has been hijacked?

Compare current answers against your baseline using dig or nslookup, querying two public resolvers and your authoritative nameserver. Hijacking signs include an A record pointing at an unfamiliar IP, a new MX host, nameservers at the registrar you didn’t set, or a certificate for your domain you never requested.

Can DNS changes happen without my site being hacked?

Yes, and that’s common. DNS lives in your registrar and DNS provider accounts, so a stolen password, a leaked API token, a compromised reseller, or an expired domain can change where your traffic goes while every file on your server stays untouched. Server scans will come back clean.


Chat with Sucuri

You May Also Like