How to Use dig and nslookup for DNS Troubleshooting

dig and nslookup are the essential command-line tools for diagnosing DNS issues — this guide covers practical usage patterns for common troubleshooting scenarios.

Basic dig Usage

dig yourdomain.com

Returns the A record and relevant details — the ANSWER SECTION shows the actual resolved IP address(es).

Querying a Specific Record Type

dig yourdomain.com MX
dig yourdomain.com TXT
dig yourdomain.com NS
dig yourdomain.com AAAA

Querying a Specific DNS Server Directly

dig @8.8.8.8 yourdomain.com

Useful for checking what a specific resolver (like Google's public DNS) currently returns, bypassing your local/ISP resolver's potentially cached answer.

Getting a Concise Answer Only

dig +short yourdomain.com

Tracing the Full Resolution Path

dig +trace yourdomain.com

Shows the complete resolution process from the root servers down through TLD servers to your domain's authoritative nameservers — useful for diagnosing delegation issues.

Checking DNSSEC Validation

dig +dnssec yourdomain.com

See How to Set Up DNSSEC for Your Domain for interpreting the results.

Basic nslookup Usage

nslookup yourdomain.com

A simpler, more universally available alternative to dig, though generally with less detailed output.

Querying a Specific Record Type with nslookup

nslookup -type=MX yourdomain.com

Reverse DNS Lookup

dig -x 203.0.113.10
nslookup 203.0.113.10

Looks up the PTR record for a given IP address — useful for verifying reverse DNS configuration, relevant to email deliverability.

Checking TTL Values

dig yourdomain.com

The TTL value appears alongside each returned record in the ANSWER SECTION — useful for understanding current caching behavior (see Understanding DNS Propagation and TTL).

Diagnosing "Domain Not Resolving" Issues

  1. Check if the domain resolves at all: dig yourdomain.com
  2. Verify the correct nameservers are set: dig yourdomain.com NS
  3. Query the authoritative nameserver directly: dig @ns1.yourdomain.com yourdomain.com
  4. Check from a different resolver to rule out local caching: dig @1.1.1.1 yourdomain.com

Checking Email-Related DNS Records

dig yourdomain.com MX
dig yourdomain.com TXT | grep spf
dig _dmarc.yourdomain.com TXT

Useful when troubleshooting email deliverability issues, checking that SPF, DKIM, and DMARC records are correctly published.

Common Errors

"connection timed out" or "no servers could be reached" — indicates a network connectivity issue reaching DNS servers themselves, separate from the domain's actual DNS configuration; check basic network connectivity first.

Continue Reading

Browse more articles in Networking & DNS.

  • dig command, nslookup tutorial, dns troubleshooting tools, dig dns query
  • 0 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

DNS Fundamentals: A, AAAA, CNAME, MX, TXT & NS Records Explained

DNS translates human-readable domain names into the information servers actually need — IP...

How to Point a Domain to Your VPS (A/AAAA Records)

Before your website is reachable at yourdomain.com instead of a raw IP address, you need to...

How to Configure MX Records for Email Delivery

MX (Mail Exchange) records tell the internet which servers handle incoming email for your domain....

How to Use CNAME Records Correctly

CNAME records let you alias one domain name to another, but they come with important restrictions...

How to Configure a Static IP on a Linux VPS

Most VPS providers assign a static (unchanging) IP address by default, but understanding how...