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.comitself (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
More tutorials like this
Why Is My Website Slow? Measure DNS, TLS and Server Time with curl
Use curl to split a web request into DNS, connection, TLS, server and download time, read the numbers correctly and fix the slow part.
How a Network Works: IP and MAC Addresses, Switches, Routers and the Path of a Packet
Learn how a network really works: IP and MAC addresses, how a switch and ARP deliver frames in the LAN, how the router and…
tcpdump Tutorial: Capture and Read Network Traffic on Linux
Capture and read network traffic with tcpdump: key options, filters, a real TCP handshake explained line by line, and pcap files for Wireshark.


