Updated 2 hours ago
When your website goes down, your first question is: is this DNS or something else?
dig and nslookup answer that in seconds. They cut through every caching layer hiding what's really happening and let you interrogate DNS directly. You can ask any nameserver on the Internet what it knows about your domain and get a straight answer.
dig vs. nslookup
nslookup ships with Windows, macOS, and Linux. No installation needed. Quick and simple.
dig (Domain Information Groper) comes from the BIND DNS suite. More verbose, more powerful, preferred for serious debugging. It's pre-installed on macOS and Linux; Windows users need to install it separately.
One thing worth knowing: nslookup is deprecated in modern BIND distributions. It still works—and always will for basic lookups—but dig is where development continues. For quick checks, either works. For real debugging, dig tells you things nslookup hides.
Your First Query
What IP address does this domain resolve to?
nslookup gives you a clean answer. dig gives you everything: the question, the answer, which server responded, how long it took, and how long the answer can be cached.
For IPv6 addresses:
Querying Different Record Types
DNS stores more than addresses:
MX Records — Where should email go?
NS Records — Which nameservers are authoritative?
TXT Records — SPF, DKIM, domain verification:
CNAME Records — Is this an alias?
Asking a Specific Nameserver
This is where real debugging starts.
By default, dig and nslookup ask your system's configured resolver—usually your ISP or corporate DNS. But when you're troubleshooting, you need to see through those caches:
With nslookup:
Here's why this matters: You just updated a DNS record. The authoritative server has your new value—you verify by asking it directly. But Google's resolver still returns the old IP. Now you know: the change is correct, you're just waiting for caches to expire.
Reading dig's Output
dig tells you everything. Here's what matters:
status: NOERROR — Query succeeded. Other values you'll see:
NXDOMAIN— Domain doesn't existSERVFAIL— Server couldn't complete the requestREFUSED— Server won't answer your query
3600 — TTL (time to live) in seconds. This record can be cached for one hour. When you're waiting for changes to propagate, this number tells you how long.
Query time: 23 msec — Useful for diagnosing slow resolution.
dig's Power Options
Just the answer:
Returns only 93.184.216.34. Perfect for scripts.
Trace the entire resolution path:
This is an X-ray of the Internet's phone book. You watch your query descend from the root servers (.) through the TLD servers (.com) down to your authoritative nameservers. You see the entire delegation chain—and exactly where it breaks when something's wrong.
Query without recursion:
Ask a server only what it knows directly, without following referrals. Shows you exactly what's in that server's zone file.
Real Debugging Scenarios
"I changed an A record but the site still shows the old IP"
Authoritative shows new, public shows old? Change is correct, caches haven't expired. Check the TTL to know how long you'll wait.
"Email isn't being delivered"
No MX records? There's your problem. MX records point to a hostname that doesn't resolve? Also your problem.
"I changed nameservers but nothing's updating"
Watch the delegation chain. If the TLD servers still point to your old nameservers, the registrar change hasn't propagated to the registry yet.
"The site loads slowly"
Look for CNAME chains in the answer. Every CNAME requires another lookup. Long chains add latency before the first byte even loads.
Quick Reference
| Task | dig | nslookup |
|---|---|---|
| A record | dig example.com | nslookup example.com |
| Specific type | dig example.com MX | nslookup -type=MX example.com |
| Specific server | dig example.com @8.8.8.8 | nslookup example.com 8.8.8.8 |
| Just the answer | dig +short example.com | — |
| Full trace | dig +trace example.com | — |
When something breaks, these tools show you what DNS actually knows—not what it should know, not what you configured, but what's true right now, from any server you choose to ask.
Frequently Asked Questions About dig and nslookup
Was this page helpful?