How DNS resolution works and how to troubleshoot it with nslookup and dig
In short: A client asks a recursive resolver, which checks its cache and, if needed, follows referrals from the root servers to the top-level domain servers and finally the domain's authoritative servers. Most DNS problems are wrong resolver settings, stale caches, missing or wrong records, or split DNS differences. dig and nslookup let you test each step directly.
The journey of a query
When you type www.example.com, your device's stub resolver sends one question to the DNS server it was given by DHCP. That server is a recursive resolver, often a domain controller, your firewall, your ISP or a public service like 1.1.1.1 or 8.8.8.8. If the answer is in its cache, it replies immediately. If not, it works it out:
- It asks a root server, which replies "I don't know, but .com is handled by these servers".
- It asks a .com TLD server, which replies "example.com is handled by ns1.example-dns.net".
- It asks that authoritative server, which gives the real answer.
- It caches every answer for its TTL and returns the result to the client.
The client's question is recursive ("give me the final answer"), while the resolver's questions are iterative ("tell me what you know or where to ask next").
Common answers and what they mean
- NOERROR with an answer: success.
- NXDOMAIN: the name does not exist. Resolvers also cache this (negative caching), for the time set in the zone's SOA.
- NOERROR with no answer: the name exists but not with that record type (for example no AAAA).
- SERVFAIL: the resolver could not get an answer, often because authoritative servers are unreachable or DNSSEC validation failed.
- Timeout: the resolver itself did not answer, often a firewall or wrong DNS server setting.
A troubleshooting method
- Which resolver is the client using?
ipconfig /allorresolvectl status. A VPN often changes it. - Ask that resolver directly:
nslookup www.example.com 10.10.5.53ordig @10.10.5.53 www.example.com. - Ask a public resolver to compare:
dig @1.1.1.1 www.example.com. If the public answer is right and the internal one is wrong, look at the internal server. - Ask the authoritative server: find it with
dig example.com NS, thendig @ns1.example-dns.net www.example.com. This shows what the zone really contains, without caches. - Follow the whole chain with
dig +trace www.example.com, which performs the root-to-authoritative walk itself. - Clear caches if the record has just changed:
ipconfig /flushdnson Windows,resolvectl flush-cacheson Linux, and the cache on internal servers.
Split DNS
Many organisations answer the same name differently inside and outside: staff get the private address of the intranet server, the internet gets the public one (or nothing). This is called split DNS or split-horizon. When something works in the office but not at home (or the other way round), compare the internal and external answers first.
Don't forget the hosts file
Before DNS, the operating system checks its hosts file (C:\Windows\System32\drivers\etc\hosts or /etc/hosts). An old test entry there overrides DNS completely and is a classic cause of "it only fails on my PC".
Real-world example: the website that only failed on Wi-Fi
Staff could reach the new booking site on mobile data but not on the office Wi-Fi. nslookup on a laptop showed the office DNS server returning an old IP address. The internal DNS had a manually created zone for the company's domain (split DNS), and nobody had added the new booking record there. Adding the record internally fixed it for everyone.
Practice
What is the difference between a recursive and an iterative DNS query?
What does NXDOMAIN mean?
Which dig option walks the resolution from the root servers down?
dig +trace.Key takeaways
- Clients ask a recursive resolver, which follows referrals from the root down.
- Answers and NXDOMAIN results are cached according to TTLs.
- Test the client's resolver, a public resolver and the authoritative server separately.
- Check split DNS and the hosts file when results differ between places.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.