You type "google.com" in your browser and a web page appears. Behind the scenes, a cascade of DNS queries translated that human-readable domain name into an IP address (like 142.250.180.14) that computers actually understand. DNS is the phone book of the internet, and every web developer needs to understand it — because when DNS breaks, everything breaks.
How DNS Resolution Works
1. You type "example.com" in your browser 2. Browser checks its local cache → Miss 3. OS checks its DNS cache → Miss 4. Query goes to your ISP's recursive resolver (e.g., 8.8.8.8) 5. Recursive resolver asks Root DNS Server: "Where is .com?" → "Ask the .com TLD server at 192.5.6.30" 6. Recursive resolver asks .com TLD Server: "Where is example.com?" → "Ask the authoritative nameserver at ns1.example.com" 7. Recursive resolver asks Authoritative Nameserver: "What's the IP for example.com?" → "93.184.216.34 (TTL: 3600 seconds)" 8. Result cached at every level → Browser connects to 93.184.216.34
DNS Record Types
A Record (Address)
Maps a domain name to an IPv4 address. The most common record type.
example.com. A 93.184.216.34 www.example.com. A 93.184.216.34
AAAA Record (IPv6)
Maps a domain name to an IPv6 address. Same as an A record but for IPv6.
example.com. AAAA 2606:2800:0220:0001:0248:1893:25c8:1946
CNAME Record (Canonical Name)
Creates an alias pointing to another domain name. Useful for subdomains and CDN setup.
www.example.com. CNAME example.com. blog.example.com. CNAME mysite.wordpress.com. cdn.example.com. CNAME d1234.cloudfront.net.
MX Record (Mail Exchange)
Specifies mail servers for the domain. Priority number determines preference (lower = higher priority).
example.com. MX 10 mail1.example.com. example.com. MX 20 mail2.example.com. (backup)
TXT Record
Stores text data. Used for domain verification (Google, Microsoft), SPF email authentication, and DKIM signatures.
# SPF — which servers can send email for your domain example.com. TXT "v=spf1 include:_spf.google.com ~all" # Domain verification example.com. TXT "google-site-verification=abc123..." # DKIM selector._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIGf..."
TTL (Time to Live)
TTL tells DNS resolvers how long to cache a record before re-querying. Measured in seconds.
- High TTL (86400 = 24 hours): Use for stable records. Reduces DNS lookups but makes changes slow to propagate.
- Low TTL (300 = 5 minutes): Use before planned changes (migrations, failovers). Changes propagate faster.
- Pro tip: Lower TTL before you make DNS changes, wait for the old TTL to expire, then make the change.
DNS Debugging Tools
# Query DNS records dig example.com A dig example.com MX dig example.com TXT # Trace the full resolution path dig +trace example.com # Simple lookup nslookup example.com # Check DNS propagation worldwide # Use online tools like dnschecker.org or whatsmydns.net
Common DNS Tasks
- Point domain to hosting: Create an A record pointing to your server's IP
- Set up email: Add MX records for your email provider (Google Workspace, Microsoft 365)
- Use Cloudflare CDN: Change nameservers to Cloudflare, which proxies your DNS and adds caching/DDoS protection
- Subdomain routing: Use A records for IP addresses, CNAME records for service aliases
- SSL certificate validation: Add a TXT or CNAME record to prove domain ownership
Common Mistakes
- CNAME at the root domain: You can't have a CNAME record on the root domain (example.com). Use an A record or ALIAS/ANAME if your provider supports it.
- Forgetting DNS propagation: Changes can take up to 48 hours to propagate worldwide. Plan accordingly.
- Not setting up SPF/DKIM/DMARC: Without these TXT records, your emails will go to spam.
Try Our Free Developer Tools
Encode URLs and decode domain-related data.