DNS (Domain Name System) translates human-readable names to IP addresses. It's the phone book of the internet, and misconfiguring it is one of the most common causes of "my site is down."
| Type | Purpose | Example |
|---|---|---|
| A | Maps name to IPv4 address | example.com → 93.184.216.34 |
| AAAA | Maps name to IPv6 address | example.com → 2606:2800:220:1:... |
| CNAME | Alias to another name | www.example.com → example.com |
| MX | Mail server for the domain | example.com → mail.example.com (priority 10) |
| TXT | Arbitrary text (verification, SPF, DKIM) | example.com → "v=spf1 include:_spf.google.com ~all" |
| NS | Nameservers for the domain | example.com → ns1.cloudflare.com |
| SRV | Service location (port + priority) | _sip._tcp.example.com → sipserver.example.com:5060 |
| CAA | Which CAs can issue certificates | example.com → "0 issue letsencrypt.org" |
# Typical DNS setup for a web app:
# Root domain → your server
example.com. A 93.184.216.34
example.com. AAAA 2606:2800:220:1::248
# www subdomain → alias to root
www.example.com. CNAME example.com.
# API subdomain → different server or load balancer
api.example.com. A 10.20.30.40
# Email (Google Workspace example)
example.com. MX 1 aspmx.l.google.com.
example.com. MX 5 alt1.aspmx.l.google.com.
example.com. TXT "v=spf1 include:_spf.google.com ~all"
# DKIM (email authentication)
google._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIGfMA0..."
# DMARC (email policy)
_dmarc.example.com. TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"
# Let's Encrypt verification
_acme-challenge.example.com. TXT "random-verification-string"
TTL tells resolvers how long to cache a record (in seconds):
| Provider | Free Tier | Best Feature | Best For |
|---|---|---|---|
| Cloudflare | Unlimited zones | CDN + DDoS + DNS in one | Most websites (recommended default) |
| AWS Route 53 | None ($0.50/zone) | Latency/geo routing, health checks | AWS-heavy infrastructure |
| Google Cloud DNS | None | Low latency, DNSSEC | GCP infrastructure |
| NS1 | Limited free | Advanced traffic management | Complex routing needs |
A CDN (Content Delivery Network) caches your content at edge locations worldwide. DNS is how you route users to the nearest edge:
# Without CDN: Users hit your origin server directly
example.com. A YOUR_SERVER_IP
# With Cloudflare (proxy mode): Users hit Cloudflare edge, which proxies to origin
# Just enable the orange cloud icon in Cloudflare dashboard
# DNS resolves to Cloudflare's anycast IPs, not your server
# With AWS CloudFront: Point domain to CloudFront distribution
example.com. ALIAS d1234567890.cloudfront.net.
# (ALIAS is AWS-specific; equivalent to CNAME at zone apex)