DNS Lookups
"It's always DNS."
Half the networking problems you'll debug come down to DNS. Let's master the tools.
dig - The Gold Standard
Short Answer
+short gives just the IP - perfect for scripts.
Query Specific Record Types
Common record types:
| Type | Contains |
|---|---|
| A | IPv4 address |
| AAAA | IPv6 address |
| MX | Mail servers |
| NS | Name servers |
| TXT | Text records (SPF, DKIM, etc.) |
| CNAME | Alias to another domain |
Query Specific DNS Server
@8.8.8.8 uses Google's DNS instead of system default. Useful for testing.
nslookup - Quick and Simple
Use Specific Server
host - Simplest Option
host IP does reverse DNS (IP to name).
Checking DNS Configuration
This shows which DNS servers your system uses.
Troubleshooting DNS
Site Won't Load - Is It DNS?
Local DNS failed, Google's works โ local DNS problem.
Wrong IP Being Returned
DNS Propagation
After changing DNS records, it can take hours to propagate. Test with different DNS servers to check propagation:
dig @8.8.8.8 site.com # Google
dig @1.1.1.1 site.com # Cloudflare
dig @9.9.9.9 site.com # Quad9
How do you check if a DNS issue is with your local DNS server specifically?
Quick Reference
| Command | Purpose |
|---|---|
dig domain | Full DNS query |
dig +short domain | Just the IP |
dig @8.8.8.8 domain | Use specific DNS server |
dig MX domain | Mail server records |
nslookup domain | Simple lookup |
host domain | Simplest lookup |
host IP | Reverse lookup |
Key Takeaways
digis the most powerful DNS tooldig +shortfor quick IP lookups- Test different DNS servers to isolate problems
- Check
/etc/resolv.conffor DNS configuration - "It's always DNS" - check DNS first when debugging
Next: making HTTP requests with curl.