“nslookup returns the new IP address, but my browser still connects to the old server.”
“dig gives me SERVFAIL. Where should I start?”
In DNS troubleshooting, what you see changes depending on which command you used, who you asked, and what you asked. If you do not know each command’s quirks, you can look at a correct result and still reach the wrong conclusion.
Through Part 7, we have covered how DNS works and how to operate it. In Part 8, we look at the tools for actually investigating it: how to use dig, nslookup, PowerShell’s Resolve-DnsName, and Linux’s resolvectl, and how to read their output.
The big picture of name resolution (the roles of the stub resolver, caching DNS, and authoritative DNS) is explained in Part 1, “What Is DNS? How Name Resolution Works and Its Three Key Players.”
▶ This part is also available as a YouTube video (about 22 min) (it is also embedded at the end of this article).
- The overall layout of dig output
- Reading the header and flags
- Sections, TTL, and query time
- The main dig options
- How to read dig +trace
- Viewing DNSSEC validation results with delv
- nslookup (one-liner and interactive mode)
- Resolve-DnsName and ipconfig (Windows)
- How dig and Resolve-DnsName correspond
- Checking in an Active Directory environment
- resolvectl (Linux’s systemd-resolved)
- How each response type looks
- Seeing DNS in a packet capture
- Think about it
- Summary
- Watch the video
- The DNS Fundamentals series (12 parts)
The overall layout of dig output
Let’s start with the output of dig www.example.com A (an excerpt). dig comes with BIND and works on Linux and macOS.
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37473
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;www.example.com. IN A
;; ANSWER SECTION:
www.example.com. 245 IN A 192.0.2.10
;; Query time: 12 msec
;; SERVER: 192.0.2.53#53(192.0.2.53) (UDP)
;; MSG SIZE rcvd: 60
Lines that start with ; are commentary. Lines without a ; are the records themselves.
- HEADER: the response code (status), the flags, and the number of records in each section. Look here first
- OPT PSEUDOSECTION: EDNS information. Extended DNS Errors (EDE) also appear here
- QUESTION / ANSWER: what was asked and what came back. The second column of the ANSWER is the remaining TTL (in seconds)
- The last four lines: the time taken, the server that answered and the transport (UDP/TCP), and the size of the response

The reading order is 1. HEADER (status) → 2. ANSWER → 3. the SERVER line. Every record type has the same five columns: name, TTL, class, type, and value.
Reading the header and flags
| Item | Example | Meaning |
|---|---|---|
| status | NOERROR / NXDOMAIN / SERVFAIL | The response code (RCODE). Check this first |
| flags: qr | qr | Indicates that this is a response |
| flags: aa | aa | The answer comes from the authoritative DNS server itself. It is not set on answers from a cache |
| flags: rd / ra | rd ra | rd = recursion was requested; ra = this server is willing to do recursion |
| flags: ad / cd | ad | ad = the resolver validated the answer with DNSSEC; cd = the client asked it not to validate |
| flags: tc | tc | The response was truncated. Ask again over TCP (Part 4) |
| Counts | ANSWER: 1, AUTHORITY: 0 | The number of records in each section. ANSWER: 0 means “no answer” |
| The OPT line | udp: 1232, flags: do, COOKIE, EDE | The EDNS buffer size, the DNSSEC request (do), the DNS Cookie, and Extended DNS Errors |
Even with status: NOERROR, if ANSWER is 0 there is no answer (NODATA). Also, if you send a query with rd to an authoritative DNS server, you see ;; WARNING: recursion requested but not available. It means the server does not do recursion for you; it is not an error.
Sections, TTL, and query time
- ANSWER: the answer (including the intermediate records if a CNAME was followed)
- AUTHORITY: the NS records of the delegated servers, or the SOA when there is no answer
- ADDITIONAL: the IP addresses of the NS servers (glue) and similar records

The number in the second column of a record is the TTL (the remaining number of seconds the record may be cached).
- Ask an authoritative DNS server, and you get the configured value itself
- Ask a caching DNS server, and you get a value that has counted down over time
If the TTL has gone down when you run the query twice, the answer is coming from a cache.
Query time is also a clue. 0 to 1 msec suggests the answer came from a cache, and tens to hundreds of msec suggests the query went all the way to an authoritative DNS server. The SERVER line shows the server that actually answered. If it is 127.0.0.53, Linux’s systemd-resolved answered.
The main dig options
| Option | Meaning | When to use it |
|---|---|---|
| @192.0.2.53 | Specifies the server to query | Compare the internal DNS, an external DNS, and an authoritative DNS directly |
| MX, AAAA, TXT, etc. | Specifies the record type (the default is A) | Check for a missing record of a given type |
| +short | Shows only the values of the answer | Scripts, comparing several servers |
| +norec | Does not request recursion (no rd) | Checking an authoritative DNS, looking inside a cache |
| +trace | Follows the delegations from the root, step by step | Finding mistakes in delegation or glue |
| -x 192.0.2.10 | Queries a reverse lookup (PTR) | Checking that a reverse record is registered |
| +tcp | Queries over TCP | Checking that TCP/53 gets through |
| +dnssec | Sets the DO bit and also shows RRSIG | Checking whether signatures exist and when they expire |
$ dig @198.51.100.53 example.com MX +norec +noall +answer
$ dig @192.0.2.53 www.example.com +dnssec +bufsize=1232 +nsid
PS> Resolve-DnsName example.com -Type MX -NoRecursion -Server 198.51.100.53 # same as the first line
Other options that are often used are +nsid (which anycast site answered), +bufsize=N (the EDNS buffer size, for checking problems where large responses get dropped), +cd (fetch the data with DNSSEC validation turned off), and +noall +answer (show only the answer).
How to read dig +trace
+trace follows the delegations from the root, step by step, and prints the response at each stage.
$ dig +trace www.example.com
. 81000 IN NS a.root-servers.net.
(omitted: the root servers' NS and RRSIG)
;; Received 525 bytes from 192.0.2.53#53(192.0.2.53) in 3 ms
com. 172800 IN NS a.gtld-servers.net.
(omitted: the com NS, DS, and RRSIG)
;; Received 834 bytes from 199.7.83.42#53(l.root-servers.net) in 12 ms
example.com. 86400 IN NS ns1.example.com.
example.com. 86400 IN NS ns2.example.com.
;; Received 120 bytes from 192.5.6.30#53(a.gtld-servers.net) in 8 ms
www.example.com. 300 IN A 192.0.2.10
;; Received 60 bytes from 192.0.2.53#53(ns1.example.com) in 5 ms
- In each block, read who was asked (Received … from) and where the query was delegated to. Only the first block gets the list of root servers from your local resolver
- dig itself does the iterative queries, so it does not go through the caching DNS. If the result differs from a normal query, suspect the cache or the resolver’s settings
- You can find delegation mistakes such as the trace stopping partway, the parent’s NS and the child’s NS being different, or a stale glue IP address (Part 2)
dig 9.20 also prints the DS and RRSIG lines. Note that on a network where machines cannot reach external DNS (UDP/TCP 53) directly, +trace fails. PowerShell has no equivalent feature; with -NoRecursion, you ask the root, the TLD, and the authoritative servers one after another.
Viewing DNSSEC validation results with delv
delv comes with BIND and is a dig that does the DNSSEC validation itself. It validates the response received from the resolver, starting from the root trust anchor built into the tool (Part 9).
$ delv www.example.com A
; fully validated
www.example.com. 300 IN A 192.0.2.10
www.example.com. 300 IN RRSIG A 13 3 300 20261009000000 20260925000000 12345 example.com. (omitted)
$ delv www.unsigned.example.com A
; unsigned answer
www.unsigned.example.com. 300 IN A 203.0.113.20
$ delv @192.0.2.53 +cd www.bad.example.org A
;; validating bad.example.org/DNSKEY: no valid signature found (DS)
;; no valid RRSIG resolving 'bad.example.org/DNSKEY/IN': 192.0.2.53#53
;; broken trust chain resolving 'www.bad.example.org/A/IN': 192.0.2.53#53
;; resolution failed: broken trust chain

The first line tells you the result.
fully validated: validation succeededunsigned answer: the zone is not signed. It is outside the scope of validation and is not a failurenegative response, fully validated: the fact that the name or record does not exist was validated
A validating resolver returns only SERVFAIL on failure, so add +cd to fetch the contents and have delv validate them. To see the validation process in detail, add +vtrace. It is important not to confuse “unsigned” with “validation failed.”
nslookup (one-liner and interactive mode)
This is the familiar nslookup on Windows.
C:\> nslookup www.example.com.
Server: dns1.corp.example.com
Address: 192.0.2.53
Non-authoritative answer:
Name: www.example.com
Address: 192.0.2.10
C:\> nslookup -type=mx example.com. 198.51.100.53
C:\> nslookup
> server 198.51.100.53
> set type=aaaa
> set debug
> www.example.com.
> exit
- The one-liner order is
nslookup -type=TYPE NAME SERVER. Put a “.” at the end of the name to prevent extra queries caused by appending search domains - In interactive mode,
set type=andserverstay in effect from then on. If the results look strange, check the current settings withset all set debugshows the HEADER (rcode and the number of answers), TTL, AUTHORITY, and ADDITIONAL- “Non-authoritative answer” means the answer came from a caching DNS (no aa). If the server name shows as UnKnown, the server simply has no reverse record
This is the point behind the question at the start. nslookup does not use the OS’s DNS client and does its own querying, so the hosts file and the NRPT (Name Resolution Policy Table) do not apply. In other words, nslookup’s result does not necessarily match what an application does.
Resolve-DnsName and ipconfig (Windows)
So to reproduce what an application does on Windows, use Resolve-DnsName.
PS> Resolve-DnsName www.example.com -Type A -Server 192.0.2.53 -DnsOnly
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
www.example.com A 245 Answer 192.0.2.10
PS> Resolve-DnsName example.com -Type MX -NoHostsFile -DnssecOk
PS> ipconfig /displaydns # Show the DNS client cache
PS> ipconfig /flushdns # Delete the cache
PS> Get-DnsClientCache ; Clear-DnsClientCache # PowerShell versions

- Resolve-DnsName resolves names by the same path as the OS’s DNS client (including the NRPT). The results come back as objects, so they are easy to handle in scripts
- Main parameters:
-Type,-Server,-DnsOnly(do not use LLMNR or NetBIOS),-NoHostsFile,-CacheOnly,-NoRecursion,-DnssecOk,-TcpOnly ipconfig /displaydnsalso shows negative cache entries meaning “the name does not exist”/flushdnsclears only the OS cache. The browser’s own cache and the caching DNS server’s cache remain
How dig and Resolve-DnsName correspond
ISC dropped Windows support starting with BIND 9.18 (January 2022), and the last Windows-supported branch, 9.16, reached end of support in April 2024. Current Windows has no built-in dig, so use PowerShell’s Resolve-DnsName.
| What you want to do | dig (Linux, macOS) | PowerShell (built into Windows) |
|---|---|---|
| Query with a type and a server | dig @192.0.2.53 example.com MX | Resolve-DnsName example.com -Type MX -Server 192.0.2.53 |
| Ask an authoritative DNS without recursion | +norec | -NoRecursion |
| Query over TCP | +tcp | -TcpOnly |
| Reverse lookup | dig -x 192.0.2.10 | Resolve-DnsName 192.0.2.10 |
| Get DNSSEC signatures / turn off validation | +dnssec / +cd | -DnssecOk / -DnssecCd |
| Query DNS only, excluding hosts and LLMNR | (always DNS only) | -DnsOnly -NoHostsFile |
| Extract just the value | +short | (Resolve-DnsName NAME).IPAddress, etc. |
| Flags, EDE, +trace, CAA / HTTPS types | Can show or run them | Cannot (check with dig on Linux or similar) |
Being able to query by the same path as the OS (cache and NRPT) is an advantage over dig. Only for checking zone transfers, use nslookup’s ls -d.
How to read Resolve-DnsName results
PS> Resolve-DnsName www.example.com -Type MX -Server 192.0.2.53 # NODATA
Name Type TTL Section PrimaryServer NameAdministrator SerialNumber
example.com SOA 900 Authority ns1.example.com hostmaster.example.com 2026092501
PS> Resolve-DnsName nosuch.example.com
Resolve-DnsName : nosuch.example.com : DNS name does not exist. # NXDOMAIN
PS> Resolve-DnsName www.bad.example.org
Resolve-DnsName : www.bad.example.org : DNS server failure. # SERVFAIL
- The TTL and Section columns correspond to dig’s ANSWER and AUTHORITY. If there is only an SOA in the Authority section, it is NODATA
- NXDOMAIN, SERVFAIL, and so on are shown as errors. EDE is not shown, so for SERVFAIL, use
-DnssecCdand see whether an answer comes back to tell whether it is a DNSSEC problem - On Japanese-language Windows these messages appear in Japanese. The kind of error can be told apart by
FullyQualifiedErrorId(DNS_ERROR_RCODE_NAME_ERRORandRCODE_SERVER_FAILURE). On Windows Server 2016, SOA and MX results are displayed as a vertical list, one item at a time - The result is an object, so you can process it. An example that lists the SOA serial number from every NS (the homework from Part 7):
PS> Resolve-DnsName example.com -Type NS | Where-Object Type -eq NS | ForEach-Object {
$ns = $_.NameHost
Resolve-DnsName example.com -Type SOA -Server $ns | Where-Object Type -eq SOA |
Select-Object @{n='NS';e={$ns}}, SerialNumber }
Checking in an Active Directory environment
When you cannot sign in to the domain or cannot join a domain, check in the following order whether the PC can find the domain controller (DC) through DNS. The example domain name is corp.example.com.
1. Can you query the DC’s SRV record?
PS> Resolve-DnsName -Type SRV _ldap._tcp.dc._msdcs.corp.example.com
Check that the DC’s host name and port 389 (LDAP) come back. If they do not, either the DNS server the PC is using is not the internal DNS (a DC), or the SRV record is not registered. You can check which DNS server the PC is using under “DNS Servers” in ipconfig /all.
2. Can the PC find a DC?
PS> nltest /dsgetdc:corp.example.com
This shows the name and address of the DC actually found through the mechanism the PC uses to look for DCs (the DC Locator). If it fails, first check the SRV record in step 1.
3. The health of DNS on the DC
PS> dcdiag /test:dns
The DNS tests run only when you specify /test:dns (they are not included in a plain dcdiag with no arguments). Run it as an administrator on a DC, or on a PC with the AD DS management tools installed, and work through the failed items in order. Microsoft’s procedure says to run it as a member of Enterprise Admins (or with equivalent permissions).
4. Register the records again
PS> ipconfig /registerdns # Re-register this PC's host records (A, etc.)
PS> Restart-Service Netlogon # On a DC: re-register the DC's SRV records
Use these when you suspect records were not registered. A DC’s Netlogon service registers its SRV records when the DC starts, when Netlogon restarts, and every hour after that. You can check the list of records it is supposed to register in %SystemRoot%\System32\Config\netlogon.dns on the DC.
The mechanics of AD-integrated DNS (SRV records, the _msdcs zone, and dynamic updates) are explained in Part 10, “DNS in the cloud and on corporate networks.”
resolvectl (Linux’s systemd-resolved)
On Linux that uses systemd-resolved (Ubuntu and others), investigate with resolvectl.
$ resolvectl query www.example.com
www.example.com: 192.0.2.10 -- link: eth0
-- Information acquired via protocol DNS in 1.8ms.
-- Data is authenticated: no; Data was acquired via local or encrypted transport: no
-- Data from: cache
$ resolvectl status eth0 # Per-link DNS servers, DNS Domain, DoT, and DNSSEC settings
$ resolvectl statistics # Cache hit counts and DNSSEC verdict counts
$ resolvectl flush-caches # Delete the cache

nameserver 127.0.0.53in/etc/resolv.confpoints to this service. If you run dig without @, systemd-resolved answers first (Part 3)resolvectl queryresolves by the same path as applications and shows whether the answer came from cache (Data from) and whether it was validated with DNSSEC (authenticated). Specify the type like-t MXresolvectl statusshows, for each link (NIC), which DNS server is used and which domains are routed to which link (DNS Domain; entries with~are for routing only). Use it to investigate “only internal names fail to resolve” while on a VPNstatisticsis handy for checking the number of cache hits and misses and timeouts
How each response type looks
As a summary of what we have covered so far, here is how each response type looks.

| Type | What dig shows | What nslookup shows | Main causes and what to check next |
|---|---|---|---|
| NOERROR | status: NOERROR, ANSWER: 1 or more | The name and Address are shown | Normal. Always read the rcode and the ANSWER count together |
| NODATA | status: NOERROR, ANSWER: 0, SOA in AUTHORITY | No error; SOA information is shown | The name exists but that type does not. A missing AAAA, MX, or similar record |
| NXDOMAIN | status: NXDOMAIN, SOA in AUTHORITY | Non-existent domain | The name does not exist. A typo, an unregistered name, or the wrong server being queried |
| SERVFAIL | status: SERVFAIL, sometimes with EDE | Server failed | Cannot reach the authoritative DNS, or DNSSEC validation failed. Isolate with +cd and EDE |
| REFUSED | status: REFUSED, EDE: 20, etc. | Query refused | Denied by an ACL, or an authoritative DNS was asked about a name it is not responsible for |
| FORMERR | status: FORMERR, a WARNING about EDNS | Format error | The other side or a device on the path cannot interpret EDNS |
| No response | communications error … timed out | DNS request timed out | Dropped by a firewall, or the server is down. Not the same as REFUSED |
Here is what it looks like in actual output.
(NODATA: the MX of www.example.com)
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40148
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
example.com. 900 IN SOA ns1.example.com. hostmaster.example.com. 2026092501 3600 900 1209600 900
(SERVFAIL: DNSSEC validation failure)
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 9270
; EDE: 9 (DNSKEY Missing): (no SEP matching the DS found for bad.example.org.)
(REFUSED: an authoritative DNS was asked recursively about a name it is not responsible for)
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 47847
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
; EDE: 20 (Not Authoritative)
- With NODATA and NXDOMAIN, an SOA is attached in AUTHORITY. The TTL of this SOA is how long the “does not exist” result is cached (negative caching, Part 3)
- EDE 9 on a SERVFAIL means “the child zone has no key that matches the parent’s DS“. A typical cause is forgetting to replace the DS when keys are rolled over (Part 9)
- REFUSED has no ra and shows a WARNING because the query went to an authoritative DNS server that does not do recursion. Check the role of the server you asked
- With FORMERR, dig prints
;; WARNING: EDNS query returned status FORMERR - retry with '+noedns'
Seeing DNS in a packet capture
When the commands do not tell you enough, look at the packets.
# tcpdump -nni eth0 port 53
IP 192.0.2.100.51234 > 192.0.2.53.53: 4660+ [1au] A? www.example.com. (44)
IP 192.0.2.53.53 > 192.0.2.100.51234: 4660 1/0/1 A 192.0.2.10 (60)
IP 192.0.2.100.40001 > 192.0.2.53.53: 1235+ [1au] AAAA? nosuch.example.com. (47)
IP 192.0.2.53.53 > 192.0.2.100.40001: 1235 NXDomain 0/1/1 (98)
In tcpdump, 4660+ is the ID and rd, [1au] is the EDNS OPT, and 1/0/1 is the number of answer, authority, and additional records. If a query is not paired with a response, it was dropped somewhere along the way.
| What you want to see | Wireshark display filter |
|---|---|
| DNS only | dns |
| A specific name | dns.qry.name == “www.example.com” |
| Error responses (NXDOMAIN is 3) | dns.flags.rcode != 0 |
| Slow responses (seconds) | dns.time > 0.5 |
| Truncated responses | dns.flags.truncated == 1 |
| Encrypted DNS (DoT, DoQ) | tcp.port == 853 or udp.port == 853 |

The trick is to capture at two points and find the segment where the responses stop.
- At 1 (client ⇔ caching DNS), queries but no responses → the caching DNS side
- At 2 (caching DNS ⇔ authoritative DNS), no response from the authoritative DNS → the authoritative DNS or the network path (firewall) side
- At both 1 and 2, queries and responses are paired → the application side
Note that DoH blends into HTTPS on port 443, so you cannot see its contents. Capture packets in accordance with your organization’s rules.
Think about it
- You run dig against the internal caching DNS and get SERVFAIL, but with
+cd(-DnssecCdin PowerShell) you get NOERROR with an answer. What is happening, and what do you check next? - nslookup returns the new IP address, but the browser still connects to the old server. Which cache do you suspect, and how do you check?
dig +traceshows the new record, but plaindigreturns the old value. What does this difference mean?
Hint: The sections of this article “Sections, TTL, and query time,” “Viewing DNSSEC validation results with delv,” “Resolve-DnsName and ipconfig (the scope of the cache),” and “How each response type looks” each lead to an answer.
Summary
- Read dig in the order HEADER (status) → ANSWER → SERVER
- If the TTL is counting down, it is a cache answer; if aa is set, it is an authoritative answer
+tracedoes not go through the caching DNS. Compare it with the normal result and look at the difference- The first line of delv tells you “unsigned” from “validation failed“
- nslookup does not go through the hosts file or the NRPT. To reproduce an application, use Resolve-DnsName or resolvectl query
- Read a response type from the rcode and the ANSWER count together. Capture at two points
Next time, we cover attacks on DNS and how to defend against them, including DNSSEC, which can be the cause of the SERVFAIL we saw here.
Watch the video
This part is also explained in a YouTube video (about 22 min).
All parts of the series are in the DNS Fundamentals playlist on YouTube.
The DNS Fundamentals series (12 parts)
All 12 parts with a reading guide: DNS Fundamentals
- What Is DNS? How Name Resolution Works and Its Three Key Players
- The domain name hierarchy and delegation
- How name resolution works
- DNS messages and transport
- Resource records, part 1
- Resource records, part 2
- Running authoritative DNS servers
- Investigating with commands (this article)
- DNS security
- DNS in the cloud and on corporate networks
- DNS troubleshooting
- DNS design exercises
This series is the English edition of 【DNS入門】, originally written in Japanese.


コメント