Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 9: Domain Names, DNS and Subdomains

9.9 Verify DNS: dig, nslookup and friends

Friends, don't guess when a domain doesn't work – use dig. This command shows exactly what answer DNS gives.

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 the cache on your laptop. Don't worry – wait for the TTL to run out or flush the cache. This one habit saves hours.

Lab

Chala, tumchya domain sathi dig example.com +short, dig @8.8.8.8 example.com +short aani dig @1.1.1.1 example.com +short chalva aani tinhi uttara jultat ka te bagha. Mag laptop var nslookup example.com chalva aani tumchya OS sathi table madhla flush command try kara.