DNS Troubleshooting with dig and nslookup: A Practical Guide

Networking 2 min readUpdated Oct 29, 2026
2 views0 comments

When a website or mail server cannot be reached, DNS is the first suspect. The good news: two commands, dig (Linux, macOS) and nslookup (Windows and everywhere), answer almost every question. This guide shows what to run and how to read the answers.

Look up a record

dig example.com A
dig +short example.com A        # just the answer

On Windows:

nslookup example.com

The record types you will actually use

Type What it answers Command
A / AAAA IPv4 / IPv6 address of a name dig +short example.com AAAA
MX Where mail for the domain goes dig +short example.com MX
TXT SPF, DKIM, verification codes dig +short example.com TXT
NS The authoritative name servers dig +short example.com NS
CNAME An alias to another name dig +short www.example.com CNAME
PTR Reverse lookup, IP to name dig +short -x 203.0.113.10

Ask a specific DNS server

Your computer asks a resolver that may hold a stale cached answer. Ask other servers directly to compare:

dig @8.8.8.8 example.com A          # Google
dig @1.1.1.1 example.com A          # Cloudflare
nslookup example.com 8.8.8.8        # Windows equivalent

If public resolvers return the new value and your machine returns the old one, the problem is a local or ISP cache, not your DNS zone.

Go to the source: the authoritative server

To see what the zone really says, with no caching in the way, query one of the domain’s own name servers:

dig +short example.com NS
dig @ns1.example-dns.com example.com A

Compare every name server. When one of them answers differently, the zone was not updated everywhere yet, which is common right after a change.

Follow the whole chain

dig +trace example.com

This walks from the root servers down to the authoritative answer and shows exactly where the chain breaks.

Read the answer

;; ANSWER SECTION:
example.com.   3600  IN  A  203.0.113.10

The number 3600 is the TTL in seconds: how long resolvers may cache this answer. If you change a record, old values can survive for up to the previous TTL. Lower the TTL a day before a planned migration.

Common mistakes

  • CNAME at the root domain. A CNAME cannot coexist with other records, so it is not allowed on example.com itself (use A records).
  • Missing or duplicated SPF record. A domain must have exactly one TXT record starting with v=spf1.
  • MX pointing at an IP address. MX records must point to a hostname.
  • Forgetting the trailing dot in some DNS panels, which makes the zone append the domain twice.

Clear your local DNS cache

# Windows
ipconfig /flushdns

# macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

# Linux with systemd-resolved
sudo resolvectl flush-caches
Did you find this helpful?Tap the heart to let us know. It takes one second and no account.

More tutorials like this

Leave a Comment

Your email address will not be published. Required fields are marked *

Bigland Network IT

Practical tutorials for people who run, build and fix things: operating systems, databases, development, networking and security.

Topics

More

Site

© 2026 Bigland Network. All rights reserved.Always test commands on a non-production system first.
Scroll to Top