# This will fail:dig example.com MX
# Returns: CNAME to something.cdn.com# CNAMEs can't coexist with other records at the same name# Use ALIAS/ANAME records instead (if your DNS supports it)
# What DNS server is the system using?cat /etc/resolv.conf
# Test if local resolver worksdig @127.0.0.1 example.com
# Bypass local DNS entirelydig @8.8.8.8 example.com
# Flush local DNS cache (varies by OS)# macOSsudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
# systemd-resolvedsudo systemd-resolve --flush-caches
# Before making changes, lower TTLexample.com. 300 IN A 93.184.216.34 # 5 minutes# Wait for old TTL to expire, then make change# After verified, raise TTL backexample.com. 86400 IN A 93.184.216.34 # 24 hours
Low TTL = faster propagation, more DNS queries.
High TTL = slower propagation, less DNS load.
#!/bin/bash
# Check if DNS has propagatedDOMAIN="example.com"EXPECTED_IP="93.184.216.34"DNS_SERVERS="8.8.8.8 1.1.1.1 208.67.222.222"for server in $DNS_SERVERS;doresult=$(dig @$server +short $DOMAIN| head -1)if["$result"="$EXPECTED_IP"];thenecho"✓ $server: $result"elseecho"✗ $server: $result (expected $EXPECTED_IP)"fidone
# "DNS isn't working"dig +short google.com
# No output? DNS server unreachable# "Website not loading"dig +short mysite.com
# Returns IP? DNS is fine, problem is elsewhere# "Email not being received"dig MX example.com +short
# No MX records? There's your problem# "SSL certificate error"dig CAA example.com +short
# CAA restricting wrong CA?
# Query root servers directlydig @a.root-servers.net example.com +trace
# Check if domain is even registeredwhois example.com
# Verify zone file syntax (if you control DNS)named-checkzone example.com /path/to/zone/file
DNS debugging is methodical: start at the source (authoritative servers), work outward (public resolvers), check caching (TTLs). Most issues are either propagation delays or configuration mistakes.
📬 Get the Newsletter
Weekly insights on DevOps, automation, and CLI mastery. No spam, unsubscribe anytime.