A name does not resolve and dig reports status: SERVFAIL. Unlike NXDOMAIN this is not an answer from the authoritative server but an error of the resolver: it could not get a valid answer. The reason is often in a line many people overlook – EDE.
Symptom
sudo ip netns exec client dig dnssec-failed.org | grep -E 'status|EDE' ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 46298 ; EDE: 9 (DNSKEY Missing): (no SEP matching the DS found for dnssec-failed.org.)
dnssec-failed.org is a test domain with a deliberately broken DNSSEC signature. The validating resolver refuses to hand out an address.
Diagnosis
Read the status line and the EDE line (Extended DNS Error) from dig's long output. EDE 9 “DNSKEY Missing” points to DNSSEC. dig +cd (checking disabled) is the counter-check: if the name gets an address with it, it is a DNSSEC problem.
sudo ip netns exec client dig dnssec-failed.org | grep -E 'status|EDE' ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 46298 ; EDE: 9 (DNSKEY Missing): (no SEP matching the DS found for dnssec-failed.org.)
Causes
EDE 9DNSSEC validation fails
The signature chain does not match (here: no DNSKEY matching the DS record of the parent zone). A validating resolver then returns SERVFAIL instead of a possibly forged address.
forwardingAuthoritative server broken or forwarding dead
If the resolver cannot reach the authoritative server or its upstream, it also reports SERVFAIL. The EDE line then names a different reason.
not SERVFAILTelling it apart from NXDOMAIN, timeout and refused
NXDOMAIN is a real answer (“the name does not exist”). A timeout means nobody answers at all; “connection refused” means the host is there but no DNS server listens.
sudo ip netns exec client dig gibtsnicht.firma.lab | grep status ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 4307
Fix
time sudo ip netns exec client dig +tries=1 +timeout=2 @10.2.0.10 example.com | head -1 ;; communications error to 10.2.0.10#53: connection refused real 0m0.073s
Don't: Switch off DNSSEC validation in the resolver so that “it works again”. Then you accept every forged answer.
Network debugging, Day 6: DNS – your own server, reading dig answers, search domains and /etc/hosts.
Go to day 6 →
FAQ
What is the difference between SERVFAIL and NXDOMAIN?
NXDOMAIN comes from the authoritative server – the name does not exist. SERVFAIL comes from the resolver – it could not obtain a valid answer, for example because of DNSSEC or a dead upstream.
What is dig +cd for?
+cd (checking disabled) skips DNSSEC validation in the resolver. If a name only resolves with +cd, its DNSSEC signature is broken.
Why does dig wait so long when no server answers?
By default it tries 3 times with 5 seconds each. With +tries=1 +timeout=2 you get “timed out” after about 2 seconds.