Chapter 9: Domain Names, DNS and Subdomains
9.9 Verify DNS: dig, nslookup and friends
dig example.com +short # A record → 13.233.10.25
dig www.example.com +short # CNAME chain → example.com. → 13.233.10.25
dig example.com # full answer incl. TTL countdown
dig @8.8.8.8 example.com +short # ask Google's public resolver
dig @1.1.1.1 example.com +short # ask Cloudflare's resolver
dig NS example.com +short # which name servers are authoritative?
dig MX example.com +short # mail records
dig +trace example.com # follow root → TLD → authoritative
nslookup example.com # works on Windows, macOS and Linux
host example.com # short output (Linux)
curl -I http://example.com # DNS + web server together
dig comes from bind-utils on Amazon Linux/CentOS (sudo yum install -y bind-utils) and dnsutils on Ubuntu (sudo apt install -y dnsutils).
Reading dig output:
;; ANSWER SECTION:
example.com. 587 IN A 13.233.10.25
name TTL(s) class type value
Flush stale caches on your laptop if the server already shows the new IP but your browser still doesn't:
| OS | Command |
|---|---|
| Windows | ipconfig /flushdns |
| macOS | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
| Linux (systemd-resolved) | resolvectl flush-caches |
| Chrome browser | open chrome://net-internals/#dns → Clear host cache |
Ravindra Bagale's Tip
When a domain "doesn't work", split the problem in two: dig example.com +short tells you if DNS is right, and curl -I http://13.233.10.25 -H "Host: example.com" tells you if the web server is right. If both pass, it's only caching on your laptop. Kalji karu naka, just wait out the TTL or flush your cache. This one habit saves hours.