DNS Deep Dive
How domain names resolve to IP addresses — registrars, nameservers, record types, TTL, and propagation
Skills taught: deployment.dns, deployment.dns-records, deployment.ttl, deployment.nameservers, deployment.dns-propagation
How DNS works — the resolution chain
DNS (Domain Name System) is the internet's phone book. Humans use domain names (google.com); computers use IP addresses (142.250.80.46). DNS translates between them. The process involves a chain of servers, each knowing only a part of the answer, until the final authoritative answer is found.
You type: myapp.com
1. Browser checks its local DNS cache → not found
2. OS checks /etc/hosts → not found
3. OS asks the Recursive Resolver (usually your ISP or 8.8.8.8)
'What's the IP for myapp.com?'
4. Resolver asks a Root Nameserver:
'Who handles .com domains?'
Root: 'Ask the .com TLD nameservers: a.gtld-servers.net'
5. Resolver asks .com TLD nameserver:
'Who handles myapp.com?'
TLD: 'Ask ns1.route53.amazonaws.com (authoritative NS for myapp.com)'
(This NS info came from the domain registrar)
6. Resolver asks Route53 (authoritative nameserver):
'What's the IP for myapp.com?'
Route53: '203.0.113.42' (the A record you set)
7. Resolver returns 203.0.113.42 to the browser
(and caches it for the TTL duration)
8. Browser connects to 203.0.113.42
The whole chain takes 20-100ms
Subsequent requests use cached results (near-instant)
DNS record types in practice
# Typical DNS setup for myapp.com:
# (configured at your DNS provider — Route53, Cloudflare, etc.)
# Root domain → CloudFront / CDN
myapp.com. A ALIAS d1234.cloudfront.net
# ALIAS (Route53) or ANAME (other providers) at the root — like CNAME but allowed at root
# www → same as root
www.myapp.com. CNAME myapp.com.
# API subdomain → your backend server
api.myapp.com. A 203.0.113.42
# Or if using load balancer:
api.myapp.com. CNAME my-alb-1234.us-east-1.elb.amazonaws.com.
# Mail server
myapp.com. MX 10 mail.myapp.com.
myapp.com. MX 20 mail2.myapp.com. # backup mail server
# Email authentication (prevents spam/spoofing)
myapp.com. TXT 'v=spf1 include:mailgun.org ~all'
_dmarc.myapp.com. TXT 'v=DMARC1; p=quarantine; rua=mailto:dmarc@myapp.com'
# Domain verification for external services
# (Google Search Console, AWS ACM certificate validation, etc.)
_abc123.myapp.com. CNAME _xyz789.acm-validations.aws.
# Check DNS records:
nslookup myapp.com
dig myapp.com A
dig myapp.com MX
dig myapp.com TXT
dig @8.8.8.8 myapp.com A # query Google's resolver specifically
TTL — time to live
TTL (Time To Live) = how long DNS resolvers cache the record (seconds)
LOW TTL (60-300 seconds):
✓ Changes propagate quickly (useful during migrations)
✗ More DNS queries = higher DNS query cost
✗ More load on authoritative nameservers
Use: before a planned IP change, disaster recovery scenarios
HIGH TTL (3600-86400 seconds = 1 hour to 1 day):
✓ Fewer DNS queries, faster resolution (cached everywhere)
✓ Works well even if your DNS provider has issues
✗ Changes take longer to propagate globally
Use: stable records that rarely change (www, root)
PRACTICAL STRATEGY:
Normal operation: TTL = 3600 (1 hour)
Before a migration: Lower TTL to 60 (wait for old TTL to expire)
After migration: Change the record, traffic shifts in 60 seconds
Post-migration: Raise TTL back to 3600
'DNS propagation' isn't magic — it's just waiting for TTLs to expire
When you change an A record with TTL=86400, some resolvers may
have cached the old IP and won't check again for up to 24 hours
Domain registrars vs DNS providers
DOMAIN REGISTRAR:
- Where you BUY the domain (Namecheap, GoDaddy, Route53, Google Domains)
- Registers your domain with ICANN
- Sets which nameservers are authoritative for your domain
- Usually also offers DNS hosting
DNS PROVIDER (authoritative nameserver):
- Where your DNS records actually LIVE
- Answers 'what IP is myapp.com?' queries
- Examples: Cloudflare DNS, Route53, Namecheap DNS
You can use different providers for each:
Buy domain at Namecheap → Use Cloudflare for DNS
Process:
1. Create Cloudflare account → Add site → Note 2 Cloudflare NS addresses
2. In Namecheap: update Nameservers to Cloudflare's NS addresses
3. Now manage all DNS records in Cloudflare
Why separate them?
Cloudflare DNS: fastest globally, free DDoS protection, free proxying
Route53: integrates with AWS ALIAS records, 100% SLA
Keep registrar where it's cheapest; use better DNS providers
Tip: Cloudflare is the best free DNS provider. It's the world's largest authoritative DNS network — typically resolving in < 10ms globally. It's free for DNS-only (no proxying needed). Move any domain's DNS to Cloudflare by updating NS records at your registrar. You get DDoS protection, DNSSEC, fast propagation, and an excellent dashboard for managing records.
Frequently Asked Questions
What is DNSSEC?
DNSSEC (DNS Security Extensions) adds cryptographic signatures to DNS records, preventing DNS spoofing attacks where a malicious resolver returns a fake IP. When you look up myapp.com, DNSSEC allows your resolver to verify the response is actually from the authoritative nameserver and hasn't been tampered with. Cloudflare and Route53 both support DNSSEC — enable it for any domain handling sensitive data.