Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

dig SERVFAIL, and it is not DNSSEC: the server does not answer for the zone

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When dig shows status SERVFAIL, the name server you asked returned RCODE 2. RFC 1035 defines that code as "Server failure - The name server was unable to process this query due to a problem with the name server." RFC 9499 uses the same sentence for the mnemonic SERVFAIL. The failure is in the server's attempt to answer, not a statement that the name does not exist. Name error is RCODE 3.

People still call one family of these faults a lame delegation. RFC 9499 quotes the old definitions and then says the term "should be considered historic and avoided" because it is used for several different flaws: a nameserver that "does not answer DNS queries", one whose address "is not reachable by the resolver", and one that "responds to a query for a specific name with an error or without the authoritative bit set." Those three are what this procedure separates. A stale DS record after a DNS provider change is a separate fault, covered in "DNSSEC SERVFAIL after changing DNS provider: the stale DS record and the safe order to move a signed zone".

What the symptom means

SERVFAIL is one response code among several. Format error means the server could not interpret the query. Refused means it "refuses to perform the specified operation for policy reasons." None of those is SERVFAIL.

A recursive resolver can also end in SERVFAIL when it never gets an answer it can use. RFC 1034 says the resolver would "wait for a response to its query or a timeout" and, on timeout, try other servers and other addresses. RFC 9520 says "Recursive servers return SERVFAIL in response to a number of different conditions" and "Authoritative servers return SERVFAIL when they don't have any valid data for a zone." The status on a recursive query can therefore be a failure the resolver met further along. The status when you ask one authoritative server is that server's own answer, or no answer at all.

dig return code 0 means "DNS response received, including NXDOMAIN status". A SERVFAIL header is still a response, so the exit code does not tell you the RCODE. Return code 9 is "No reply from server", which is a timeout rather than a SERVFAIL header.

The AA bit in the header "specifies that the responding name server is an authority for the domain name in question section." A reply without that bit is not that server claiming authority. The dig manual's default is a verbose answer, which is where the status is printed. +short is only a terse answer.

Likely causes

Cause What you see How to confirm
The listed server does not answer dig to that server exits 9, "No reply from server" dig @ that server, with a timeout
The server answers with server failure The verbose header says SERVFAIL The same direct query
The server answers but is not authoritative The reply is not an authoritative answer for the name The AA bit, as RFC 1035 defines it, in the verbose header
The recursive resolver gave up Your resolver returns SERVFAIL, and a direct query does not Compare dig with no @ to dig @ the listed server
DNSSEC validation may have failed A query with +cd, which asks the server not to validate, returns the data, and a query without it is SERVFAIL +cd, then "DNSSEC SERVFAIL after changing DNS provider: the stale DS record and the safe order to move a signed zone" if a provider change left a stale DS

Prove the cause before changing anything

All of these are read-only. The manual's form is dig @server name type. +trace "makes iterative queries to resolve the name being looked up" and "follows referrals from the root servers, showing the answer from each server". +cd "requests the server to not perform DNSSEC validation of responses." The default query type is A.

1. Read the status in the verbose answer.

dig example.com A

Do not use +short. Note SERVFAIL, REFUSED, or a normal answer. This query uses the servers in /etc/resolv.conf unless you pass @server.

2. Ask again with validation disabled.

dig +cd example.com A

If this returns the records and step 1 was SERVFAIL, validation may be what failed, because +cd asks the server not to validate. Follow "DNSSEC SERVFAIL after changing DNS provider: the stale DS record and the safe order to move a signed zone" when the zone was signed and the DNS provider changed. If +cd is still SERVFAIL, validation is not what produced this status.

3. Ask a listed server directly.

dig @ns1.example.net example.com A

Use a nameserver name or address from the delegation, not the recursive resolver. Exit 9 means that server sent no reply. A SERVFAIL header means it replied with server failure. An answer with the AA bit set is that server claiming authority.

4. Walk the delegation.

dig +trace example.com A

Compare the servers at the end of the trace with the servers you edit. A mismatch means the internet is asking a different set.

Fix

The server named by the delegation has to answer the name, or the delegation has to name a server that does. Changing the delegation moves the whole zone.

Save the current delegation first. This command saves the zone's NS answer, and the manual's +noall +answer form prints "the name, record type, TTL, and value for each answer":

dig +noall +answer example.com NS > ns-before.txt

Then copy the registrar's current NS list into a second file named registrar-ns-before.txt. The registrar's list is the one the back-out restores.

Risk: replacing the NS set moves mail, web and every other name in the zone to the new servers. A server that is empty or that does not have the zone will serve the wrong data, or none, until you restore the saved set. A signed zone is a different fault. Use "DNSSEC SERVFAIL after changing DNS provider: the stale DS record and the safe order to move a signed zone" before you change that delegation.

At the registrar, set the NS names to servers that answer for the zone. Then query the new server with dig @ that server.

To undo it, put the NS list saved in registrar-ns-before.txt back at the registrar. The previous servers answer again only if they still have the zone.

Example (illustrative): dig example.com A returns SERVFAIL, and dig +cd example.com A does too. dig +trace example.com A ends at ns1.example.net. dig @ns1.example.net example.com A exits 9, so that server sends no reply. dig @ns2.example.net example.com A returns the address with the AA bit set. The administrator saves the NS list, replaces ns1.example.net with ns2.example.net at the registrar, and then dig +trace example.com A ends at ns2.example.net and dig example.com A returns the address. Restoring the saved NS list at the registrar puts ns1.example.net back.

Confirm the fix

  1. dig @ each listed server returns the record, with the AA bit set, and does not return SERVFAIL.
  2. dig +trace ends at those servers.
  3. A query with no @ returns the record. If the direct query succeeds and the recursive query is still SERVFAIL, the resolver has not started returning the repaired answer. RFC 9520 section 3.2 says "resolution failures MUST NOT be cached for longer than 5 minutes", so a resolver that cached the failure can keep returning it for up to five minutes.

What to watch afterwards

  • After a provider change, check +cd before you treat the fault as a dead server. A stale DS is the separate fault described in "DNSSEC SERVFAIL after changing DNS provider: the stale DS record and the safe order to move a signed zone".
  • Return code 9 and a SERVFAIL header are different. One is silence. The other is an explicit server failure.
  • REFUSED can be policy toward the asker. RFC 9520 also says "Authoritative servers generally return REFUSED when processing a query for which they are not authoritative", so a server listed for a zone it does not serve can return it. Ask from another network before you change the delegation.

Risks and limits

  • RFC 9499 says not to use "lame delegation" as if it named one fault. The checks above separate no reply, SERVFAIL, and a reply that is not authoritative.
  • +cd asks the server not to validate. It does not repair a zone.
  • The dig manual does not print a sample header. Read the status in the verbose reply. The meaning of that status is RFC 1035's RCODE.

Sources