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 वापरा. ही कमांड DNS नेमकं काय उत्तर देतं ते दाखवते.
दोस्तों, डोमेन नहीं चल रहा तो अंदाज़ा मत लगाओ – dig इस्तेमाल करो. ये कमांड दिखाती है कि DNS ठीक-ठीक क्या जवाब देता है.
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.
Ravindra Bagale's Tip – मराठी
Domain "चालत नाही" तेव्हा problem चे दोन भाग करा: dig example.com +short सांगतो DNS बरोबर आहे का, आणि curl -I http://13.233.10.25 -H "Host: example.com" सांगतो web server बरोबर आहे का. दोन्ही pass झाले तर फक्त तुमच्या laptop वर cache आहे. काळजी करू नका, TTL संपेपर्यंत थांबा किंवा cache flush करा. ही एक सवय तासन्तास वाचवते.
Ravindra Bagale's Tip – हिंदी
Domain "नहीं चल रहा" तब problem के दो हिस्से करो: dig example.com +short बताता है कि DNS सही है या नहीं, और curl -I http://13.233.10.25 -H "Host: example.com" बताता है कि web server सही है या नहीं. दोनों pass हुए तो बस आपके laptop पर cache है. चिंता मत करो, TTL खत्म होने तक रुको या cache flush करो. ये एक आदत घंटों बचाती है.
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.