
Monitoring DNS: resolvers, authoritative servers and the checks that matter
When DNS breaks, the first report almost never says "DNS". It says the network is slow, or email is down, or the
internet is broken on the third floor. By the time someone runs dig, a good part of the incident is already
gone. That is the argument for monitoring DNS directly instead of inferring it from everything that depends on it.
The catch is that "DNS" names two different services that happen to share a port, and they fail in different ways. Monitor them separately, with different questions, and alert on them differently.
Two services on one port
A recursive resolver answers your own clients. A laptop asks it for www.example.net, and the resolver walks the
tree from the root down, caches what it learns and hands back an answer. Your users depend on it for almost every
connection they make, and it usually lives inside your network: a pair of Unbound or BIND servers, the firewall's
DNS service, or a small board on a shelf in a home lab.
An authoritative server answers the rest of the world about your zones. It holds the records for example.com and
answers only for those. When it fails, people outside cannot reach your web site or deliver mail to you, while
everything looks fine from the inside, because your own resolvers still have the answers in cache.
Both speak the protocol defined in RFC 1035, on UDP and TCP port 53. The questions a check asks are different. A resolver check asks "can you find this answer for me, and how fast?" An authoritative check asks "are you a source for this zone, and are you serving the current version of it?"
How DNS fails, and what catches it
| Failure | What users notice | Check that catches it |
|---|---|---|
| The first resolver handed out by DHCP is down | Everything is slow; pages start after a pause | Query each resolver directly, by address |
| A resolver can no longer recurse (upstream path, firewall change) | Cached names work, new ones fail | Resolve a name that cannot be in the cache |
| A resolver is overloaded | Timeouts at busy hours | Response time and dropped queries from the resolver's own statistics |
| A secondary missed a zone change | Some visitors get the old address | Compare the SOA serial on every authoritative server |
| A secondary has not reached its primary for too long | That server stops answering for the zone | A direct query to each server, plus a heartbeat record |
| The parent lists a server that no longer serves the zone (lame delegation) | Slow or failed lookups from some resolvers | Compare the parent's NS records with the zone's own |
| DNSSEC signatures expired, or the DS record at the parent is wrong | Validating resolvers return SERVFAIL, others work | Signature expiry check and a query through a validating resolver |
| The domain registration lapsed | Everything, everywhere, spreading as caches expire | Registration expiry date from RDAP or WHOIS |
| A wrong record was published | The right name points at the wrong place | Compare answers with an expected value |
Two rows deserve a note. The DHCP row is the one I see most in small networks, and it hides well. With the first
resolver dead, a Linux client using glibc waits for a timeout before it tries the second one, 5 seconds by default
according to resolv.conf(5), and it pays that wait on every lookup that is not already cached. Nothing is down.
Everything is just slow, and the ticket says "Wi-Fi problems".
The DNSSEC row is nasty for the opposite reason. Some users fail and some do not, depending on whether their resolver validates, so the reports look random until someone asks which resolver each person was using.
Checks for resolvers
Query each resolver by its address. A check that goes through the monitoring host's own system resolver tests whichever server answers first, which hides exactly the failure in the first row.
dig @10.0.0.53 www.example.net A +tries=1 +time=2
dig @10.0.0.54 www.example.net A +tries=1 +time=2
A healthy reply has status: NOERROR, an answer section and a query time. The +tries=1 +time=2 options stop the
check from retrying its way to a pass.
Cached answers are cheap, so a check that always asks for the same popular name mostly tests the cache. To test
recursion itself, ask for something the resolver cannot have cached. A unique label under a zone you control works
well: query chk-1795608000.probe.example.com, with the current Unix time in the label, and expect NXDOMAIN. A fast
NXDOMAIN means the resolver could still walk the tree, as far as its cache required, and reach your own servers. A
timeout or SERVFAIL means recursion is broken, even while cached names keep working for a while. Keep the probe zone
unsigned, or a validating resolver may answer from cached NSEC records without asking anyone.
Then read the resolver's own numbers. With remote control enabled, Unbound reports them like this:
sudo unbound-control stats_noreset | grep -E 'total.num.(queries|cachehits|cachemiss)|total.recursion.time|total.requestlist.exceeded'
Use stats_noreset. Plain stats resets the counters each time it runs, which quietly breaks any other tool that
reads them. The total.num values are counters, so graph them as rates. total.recursion.time.avg and
total.recursion.time.median are in seconds and show how long cache misses take. total.requestlist.exceeded
counts queries dropped because the request list was full, and it should stay at zero. Turn on
extended-statistics: yes in unbound.conf and you also get answers per return code, such as
num.answer.rcode.SERVFAIL, which is the nearest thing a resolver has to an error rate. BIND exposes similar
numbers through its statistics channel; the names differ, the ideas do not.
Checks for authoritative servers
Ask each server directly, without recursion, and look for the authoritative answer flag:
dig @198.51.100.53 example.com SOA +norecurse
In the header, the aa flag means the server answered as an authority for the zone. If aa is missing, or the
status is SERVFAIL or REFUSED, that server is not serving the zone, whatever the parent's NS records claim. Run the
check against every server in the NS set, by address, over UDP and once over TCP as well (+tcp). Large answers,
DNSSEC ones especially, need TCP, and RFC 7766 makes TCP support a
requirement rather than an option. A firewall rule that only allows UDP 53 breaks those answers and nothing else.
Next, compare serials:
dig +nssearch example.com
dig +short SOA example.com @198.51.100.53
+nssearch finds the zone's name servers and prints the SOA record each one returns. The +short form prints the
fields in order: primary server, contact, serial, refresh, retry, expire and minimum, for example
ns1.example.com. hostmaster.example.com. 2026112401 7200 3600 1209600 3600. Every server should show the same
serial within minutes of a change. NOTIFY, from RFC 1996, normally prompts the secondaries to transfer within
seconds, and the refresh timer is the fallback when a NOTIFY is lost.
The expire field is the one to respect. If a secondary cannot refresh from its primary for that long, here 1,209,600 seconds or 14 days, it stops answering for the zone. The last field sets how long resolvers cache a "no such name" answer, as RFC 2308 describes, which is why a typo fixed in a hurry can keep failing for a while.
A heartbeat record
A matching serial tells you a transfer happened at some point. It does not tell you the transfer path works right
now, after six quiet weeks with no edits. For that, publish a heartbeat: a job on the primary updates a TXT record
such as _heartbeat.example.com with the current Unix time every 15 minutes, and the monitor reads it from every
authoritative server and raises a ticket when any copy is more than 45 minutes old. That proves the whole chain,
from edit to serial to NOTIFY to transfer, every quarter of an hour. It also catches the zone edit made in a hurry
the afternoon before a long holiday weekend, the one with a typo that makes the primary refuse to reload the zone.
The heartbeat stops moving, and you hear about it before the weekend starts rather than after it.
The guide to writing a custom check covers turning a small script like this into an alert.
Delegation and DNSSEC
Compare what the parent zone says with what your servers say:
dig +trace example.com NS
dig @198.51.100.53 example.com NS +norecurse
In the trace, the step before the final answer is the parent's referral, which lists the delegated NS set. That
set and the zone's own NS records should name the same servers, and each of them should pass the aa check above. A server that appears in the delegation but not in
the zone, or answers without aa, is a lame delegation, and some resolvers will waste a timeout on it.
For a signed zone, dig @198.51.100.53 example.com SOA +dnssec +multi shows the RRSIG record with its expiration
timestamp. Signers re-sign on a schedule, so that date should keep moving forward. Alert on the date itself, not
just on validation failures: an expiry that stops moving means the signer stopped, and you get days of warning
instead of none. Then validate from a user's point of view with delv @10.0.0.53 example.com SOA, which should
report the answer as fully validated.
If you run Prometheus
The blackbox exporter has a DNS prober that covers most of this. A module for the authoritative check:
modules:
dns_soa_auth:
prober: dns
timeout: 3s
dns:
query_name: "example.com"
query_type: "SOA"
recursion_desired: false
preferred_ip_protocol: "ip4"
valid_rcodes:
- NOERROR
Point it at each server's address as the target. Set preferred_ip_protocol deliberately, because the default
prefers IPv6, and set query_type, because the default is ANY. Details are in the documentation at
prometheus.io.
What pages and what opens a ticket
| Signal | Alert | Reason |
|---|---|---|
| A key public name fails to resolve from two of three outside locations for 3 minutes | Page | Users feel it now |
| Every resolver at one site fails 3 checks in a row | Page | Nothing on that site can connect |
| One resolver fails while its partner is healthy | Urgent ticket, same day | Users are slow, not down |
One authoritative server fails the aa check |
Ticket | The others answer; fix before the next one goes |
| SOA serials disagree for more than 30 minutes, or the heartbeat is stale | Ticket | A change has not reached everyone |
| Earliest RRSIG expiry less than 3 days away | Ticket, then a page at 24 hours | A stalled signer has a deadline |
| Registration expires within 30 days | Ticket, page at 7 days | Renewal is a human task |
| Resolver SERVFAIL rate or recursion time trending up | Dashboard, ticket on trend | Early warning, not an outage |
The split follows the usual rule: page on what users feel, open tickets for causes and early warnings. The layered check plan in the ping article applies the same rule to a web service, and the alert fatigue piece explains why the ticket column should be the longer one.
If you set up only three of these, start with a direct query to each resolver by address, an SOA serial comparison across your authoritative servers, and a registration expiry date in somebody's calendar. Those three cover the failures that are both common and slow to diagnose.
next: SNMP counter to bit rate for the numbers, the Rack list for the gear


