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:
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.
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.
| Record | What it does | What a malicious change looks like |
|---|---|---|
| A / AAAA | Points a hostname at an IPv4 or IPv6 address | An IP you don’t recognize, or a hosting provider you’ve never used; sometimes only on a subdomain so the homepage looks normal |
| CNAME | Aliases one hostname to another | www or a subdomain aliased to a third-party host; a CNAME added where an A record used to be |
| NS | Delegates the zone to nameservers | Nameservers you didn’t set, which hands the whole zone over at once; the most damaging single edit |
| MX | Says which servers accept your email | An unfamiliar mail host, or a new MX with a lower priority number so it wins over yours |
| TXT | Holds SPF, DKIM, DMARC, and provider verification strings | A 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 |
| CAA | Limits which certificate authorities may issue for your domain | The record removed, or an extra CA added |
| TTL values | How long resolvers cache each answer | A 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.
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.comdig +short NS yourdomain.comdig +short TXT yourdomain.comOn 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" [email protected] < "$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?.
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:
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.
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.
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.
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.
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.
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.
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.