DNS: The Phonebook Nobody Thinks About Until the Internet Dies
DNS is the internetâs most critical invisible infrastructure. When it works, nobody notices. When it breaks, everything stops working and suddenly everyoneâs a DNS expert with opinions about TTL values.
Understanding DNS isnât academicâitâs survival. One misconfigured record can take your entire application offline. One wrong TTL setting can turn a 5-minute fix into a 24-hour outage.
Hereâs how DNS actually works and how to avoid the footguns that will ruin your weekend.
The DNS Hierarchy: Delegation All the Way Down
DNS is a distributed system built like a corporate org chartâeveryone passes the buck until someone actually knows the answer.
When you type dualpony.com into your browser, hereâs the conversation that happens in milliseconds:
-
Your computer asks the root servers (.): âWho handles .com domains?â
- Root servers: âAsk the .com TLD servers at these IP addressesâ
-
Your computer asks .com TLD servers: âWho handles dualpony.com?â
- TLD servers: âAsk dualponyâs authoritative nameserversâ
-
Your computer asks authoritative nameservers: âWhatâs the IP for dualpony.com?â
- Authoritative servers: âHereâs the actual IP address: 192.168.1.1â
This hierarchical delegation is why DNS is both incredibly resilient and occasionally maddening. Changes propagate through multiple layers of caching, each with their own ideas about how long to remember things.
TTL: Time To Live (And Time To Regret Your Choices)
TTL is how long DNS records get cached before being refreshed. Set it wrong and youâre either waiting forever for changes to take effect or getting billed for excessive DNS queries.
Common TTL values and their trade-offs:
- 86400s (24 hours): Great for records that never change, terrible for anything you might need to update quickly
- 3600s (1 hour): Good default for most records
- 300s (5 minutes): Use before making changes, then increase afterward
- 60s (1 minute): Emergency mode onlyâyour DNS provider will start charging extra
Pro strategy: Before any significant DNS change, lower your TTL to 300s about 24 hours in advance. Make your change, verify it works globally, then bump the TTL back up to 3600s. This gives you a quick escape route if things go wrong.
DNS Records: The Essential Types
A and AAAA Records: The Basic Building Blocks
dualpony.com. A 192.168.1.1 # IPv4 address
dualpony.com. AAAA 2001:db8::1 # IPv6 address
CNAME: The Alias That Causes Confusion
CNAME records point one domain name to another domain name (not an IP address):
www.dualpony.com. CNAME dualpony.com.
cdn.dualpony.com. CNAME d1234.cloudfront.net.
Critical rule: You cannot have a CNAME record alongside any other record type for the same name. This breaks things in weird, unpredictable ways.
MX Records: Emailâs Special Snowflake
Email routing uses MX records with priority numbers (lower number = higher priority):
dualpony.com. MX 10 mail.dualpony.com.
dualpony.com. MX 20 backup-mail.dualpony.com.
The trailing dot matters. mail.dualpony.com without a trailing dot becomes mail.dualpony.com.dualpony.com. and your emails disappear into the DNS void.
TXT Records: The Junk Drawer of DNS
TXT records hold arbitrary text and are used for everything from email authentication to domain verification:
dualpony.com. TXT "v=spf1 include:_spf.google.com ~all"
dualpony.com. TXT "google-site-verification=abc123def456"
Common DNS Footguns That Will Destroy Your Day
The CNAME Root Domain Trap
You cannot put a CNAME record on your root domain (dualpony.com) because it conflicts with required records like MX and NS. Some DNS providers let you do it anyway, but it breaks email and other services unpredictably.
Wrong:
dualpony.com. CNAME cdn.dualpony.com. # This breaks everything
Right:
dualpony.com. A 192.168.1.1
www.dualpony.com. CNAME cdn.dualpony.com.
Wildcard Records: The Footgun That Keeps Giving
*.dualpony.com seems convenient until you realize it catches everything:
*.dualpony.com. A 192.168.1.1
This matches:
api.dualpony.comâ (intended)staging.dualpony.comâ (intended)secret-admin-panel.dualpony.comđ± (unintended)literally-anything.dualpony.comđ± (unintended)
Better approach: Create explicit records for each subdomain you actually need.
The Propagation Myth That Wonât Die
âDNS propagation takes 24-48 hoursâ is the biggest lie in web development. Hereâs what actually happens:
- Your authoritative DNS server updates instantly
- Recursive resolvers worldwide cache records for the TTL duration
- Your browser caches DNS responses (often ignoring TTL)
- Your operating system caches DNS responses too
Most âpropagationâ issues are local caching problems, not global DNS delays.
Quick debugging:
# Check what your system is seeing
nslookup dualpony.com
# Bypass all caches, query authoritative server directly
nslookup dualpony.com 8.8.8.8
# Force refresh on Windows
ipconfig /flushdns
# Force refresh on macOS/Linux
sudo dscacheutil -flushcache
Email DNS: The Special Circle of Hell
If your application sends email, you need these DNS records or your messages will end up in spam folders:
SPF: Sender Policy Framework
Tells email providers which servers are allowed to send email for your domain:
dualpony.com. TXT "v=spf1 include:_spf.google.com ~all"
DMARC: Domain-based Message Authentication
Tells email providers what to do with emails that fail authentication:
_dmarc.dualpony.com. TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@dualpony.com"
Start with p=none to monitor before enforcing. Going straight to p=reject can block legitimate emails.
DKIM: DomainKeys Identified Mail
A cryptographic signature that proves emails actually came from your domain. Your email provider usually handles this, but youâll need to add their public key to your DNS:
selector._domainkey.dualpony.com. TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3..."
Testing and Monitoring: Donât Learn About DNS Problems From Users
Essential Tools
- whatsmydns.net: Shows DNS resolution from servers worldwide
- dig: The power userâs DNS lookup tool (built into macOS/Linux)
- DNSChecker: Validates your records before you push changes
Testing Commands That Actually Help
# Check A record
dig dualpony.com A
# Check MX records for email
dig dualpony.com MX
# Trace the full DNS resolution path
dig +trace dualpony.com
# Check a specific DNS server
dig @8.8.8.8 dualpony.com
Monitoring That Matters
Set up monitoring for your critical DNS records. Services like UptimeRobot or Pingdom can alert you when DNS resolution fails before your users notice.
Monitor these records:
- Your main domain (A/AAAA records)
- www subdomain (CNAME)
- MX records (email delivery)
- Any subdomains critical to your application
DNS Disaster Recovery: When Everything Is On Fire
The Emergency Checklist
- Donât panic-edit everythingâyouâll make it worse
- Verify the problem is actually DNSâtest with IP addresses directly
- Check your authoritative nameserversâare they responding?
- Review recent changesâDNS problems are usually human error
Quick Fixes for Common Problems
- Wrong IP address: Fix the A record and wait for TTL to expire
- Broken CNAME: Verify the target domain resolves correctly
- Missing subdomain: Add the record and flush local DNS cache
- Email not delivering: Check MX records and SPF/DMARC configuration
The Nuclear Option
If youâve completely broken your DNS:
- Contact your domain registrarâthey can help fix nameserver records
- Use a CDN as a proxyâCloudflare can route traffic while you fix DNS
- Communicate via social mediaâemail might be broken too
DNS Security: Beyond Basic Setup
DNSSEC: Cryptographic DNS Verification
DNSSEC cryptographically signs DNS records to prevent hijacking attacks. Itâs technically elegant and operationally complex. Unless youâre handling sensitive financial data, the complexity usually outweighs the benefits.
DNS-over-HTTPS (DoH) and DNS-over-TLS (DoT)
These encrypt DNS queries to prevent eavesdropping. Most modern browsers support DoH automatically, but be aware it can complicate corporate network filtering and monitoring.
Real-World DNS Best Practices
Provider Selection
Donât use your registrarâs free DNSâitâs usually slow and unreliable. Use a dedicated DNS service:
- Cloudflare: Fast, free tier available, excellent uptime
- Route 53: Expensive but integrates well with AWS
- NS1: Advanced features for complex setups
Configuration Management
Document everything. DNS configurations that arenât documented are DNS disasters waiting to happen. Keep a record of:
- What each record does
- When it was last changed and why
- Dependencies between records
- Emergency contact information for your DNS provider
Backup Strategy
Have a secondary DNS provider configured. Most registrars let you set multiple nameservers. Configure identical records on two different providers so you can switch quickly if one goes down.
The Bottom Line
DNS is invisible until it breaks, then it breaks everything. The key to DNS success is:
- Understand the caching layersâmost problems are caching problems
- Use appropriate TTL valuesâbalance between performance and flexibility
- Test changes thoroughlyâDNS mistakes affect everyone immediately
- Monitor critical recordsâknow about problems before your users do
- Have a disaster recovery planâbecause DNS always breaks at the worst time
DNS was designed by people who expected everything to fail gracefully. Your DNS strategy should embrace the same philosophy: plan for failure, monitor everything, and always have a backup plan.