DNS and Domains Explained for Web Developers
Muhammad Bilal Azhar
Co-Founder & Technical Lead · Google Cloud Certified Professional
DNS and Domains Explained for Web Developers
DNS is the phone book of the internet. It translates domain names (google.com) into IP addresses (142.250.80.46). Here's what developers need to know.
How DNS Works
When you type example.com in a browser:
1. Browser checks cache
2. OS checks cache
3. Query goes to DNS resolver (ISP or 8.8.8.8)
4. Resolver asks root servers → .com servers → example.com nameservers
5. IP address returned
6. Browser connects to that IP
All this happens in milliseconds.
Key Terminology
Domain Name
The human-readable address: example.com
Parts:
com- Top-level domain (TLD)
example- Second-level domain
www- Subdomain (optional)
Registrar
Where you buy domains: Namecheap, Cloudflare, GoDaddy, etc.
Nameservers
The servers that know your domain's DNS records:
ns1.example.com
ns2.example.com
DNS Records
Entries that tell computers where to find things.
Common DNS Records
A Record
Maps domain to IPv4 address.
Type: A
Name: @
Value: 76.76.21.21
TTL: 3600
@ means the root domain (example.com).
Use for: Pointing domain to a server IP.
AAAA Record
Maps domain to IPv6 address.
Type: AAAA
Name: @
Value: 2606:4700::1
Use for: IPv6 support.
CNAME Record
Alias one domain to another.
Type: CNAME
Name: www
Value: example.com
Use for: Making www.example.com go to example.com.
Important: CNAME cannot be used on root domain (@).
MX Record
Mail server configuration.
Type: MX
Name: @
Value: mail.example.com
Priority: 10
Use for: Email delivery. Priority determines preference (lower = higher priority).
TXT Record
Text information for verification and security.
Type: TXT
Name: @
Value: "v=spf1 include:_spf.google.com ~all"
Use for:
- SPF (email security)
- DKIM (email signing)
- Domain verification
- DMARC policies
NS Record
Specifies nameservers for the domain.
Type: NS
Name: @
Value: ns1.vercel-dns.com
Use for: Delegating DNS to a provider.
Common Configurations
Pointing Domain to Vercel
Option 1: A Record
Type: A
Name: @
Value: 76.76.21.21
Type: CNAME
Name: www
Value: cname.vercel-dns.com
Option 2: Nameservers (Recommended)
Update nameservers at registrar to:
ns1.vercel-dns.com
ns2.vercel-dns.com
Vercel then manages all DNS.
Pointing Domain to Netlify
Type: A
Name: @
Value: 75.2.60.5
Type: CNAME
Name: www
Value: example.netlify.app
Pointing Domain to Cloudflare Pages
Type: CNAME
Name: @
Value: example.pages.dev
(Cloudflare allows CNAME at root)
Email with Google Workspace
Type: MX
Name: @
Priority: 1
Value: smtp.google.com
Type: MX
Name: @
Priority: 5
Value: smtp2.google.com
Type: TXT
Name: @
Value: "v=spf1 include:_spf.google.com ~all"
TTL (Time to Live)
How long resolvers cache records (in seconds).
| TTL | Duration | Use Case |
| 60 | 1 minute | During DNS changes |
| 3600 | 1 hour | Standard |
| 86400 | 24 hours | Stable records |
Before changing DNS: Lower TTL first, wait, then change.
After changes work: Increase TTL for performance.
DNS Propagation
When you change DNS, it takes time to spread globally.
Why?
DNS resolvers cache records based on TTL. Until old cache expires, some users see old records.
How Long?
| Scenario | Typical Time |
| Low TTL (60s) | Minutes |
| Standard TTL | 1-4 hours |
| High TTL | Up to 48 hours |
What If Old DNS Not Propagating?
1. Wait longer
2. Try different DNS (8.8.8.8, 1.1.1.1)
3. Clear local DNS cache:
- Mac: sudo dscacheutil -flushcache
- Windows: ipconfig /flushdns
Debugging DNS
Command Line Tools
dig (Mac/Linux):
dig example.com A
dig example.com MX
dig example.com TXT
dig +short example.com
nslookup (Windows):
nslookup example.com
nslookup -type=MX example.com
Online Tools
- DNS Checker - Check propagation globally
- MX Toolbox - Email/DNS diagnostics
- WhatsMyDNS - Global propagation
What to Check
1. A record exists and is correct
2. Nameservers are set properly
3. No conflicting records
4. TTL is reasonable
Subdomains
Subdomains are prefixes to your domain:
blog.example.com
app.example.com
staging.example.com
Creating Subdomains
Add DNS records with the subdomain name:
Type: A
Name: blog
Value: 192.168.1.1
Or CNAME:
Type: CNAME
Name: staging
Value: staging-app.vercel.app
Wildcard Subdomains
Match any subdomain:
Type: A
Name: *
Value: 192.168.1.1
Now anything.example.com points to that IP.
SSL/HTTPS
Modern hosting provides free SSL:
| Provider | SSL |
| Vercel | Automatic |
| Netlify | Automatic |
| Cloudflare | Automatic |
| Let's Encrypt | Free, needs setup |
With platforms like Vercel, just point your domain and SSL is issued automatically.
Common Mistakes
CNAME at Root
BAD - Won't work on all providers
Type: CNAME
Name: @
Value: example.vercel.app
Use A record for root domain unless provider supports CNAME flattening (Cloudflare does).
Conflicting Records
BAD - Both A and CNAME for www
Type: A
Name: www
Value: 192.168.1.1
Type: CNAME
Name: www
Value: example.vercel.app
Only one can exist for the same name.
Wrong Priority on MX
Lower priority = higher preference:
Preferred mail server
Priority: 1
Value: smtp.google.com
Backup mail server
Priority: 10
Value: backup.google.com
Forgetting www
Configure both:
@ → A record to server
www → CNAME to @ or server
Buying Domains
Good Registrars
| Registrar | Pros |
| Cloudflare | At-cost pricing, good DNS |
| Namecheap | Affordable, free WHOIS privacy |
| Porkbun | Low prices, quirky brand |
| Google Domains | Simple (now Squarespace) |
Avoid
- GoDaddy (expensive renewals, upsells)
- Domain.com (high prices)
What to Look For
- Free WHOIS privacy
- Not inflated renewal prices
- Easy DNS management
- No price lock-in
Quick Reference
| Record | Purpose | Example Value |
| A | IP address | 76.76.21.21 |
| AAAA | IPv6 address | 2606:4700::1 |
| CNAME | Alias | example.vercel.app |
| MX | Mail server | smtp.google.com |
| TXT | Text data | "v=spf1 ..." |
| NS | Nameserver | ns1.vercel-dns.com |
Conclusion
DNS basics for developers:
1. A record = domain to IP
2. CNAME = alias to another domain
3. MX = email server
4. TXT = verification and email security
5. TTL = cache duration
6. Propagation = takes time after changes
Most modern platforms make this easy. Point your domain, they handle the rest.
Related guides:
Related Articles
View allVercel vs Netlify vs Cloudflare Pages: Which to Choose in 2026
Compare the top static site hosting platforms. Deployment, features, pricing, and performance breakdown to help you choose.
Deploying to Vercel: Step-by-Step Guide
Deploy your first project to Vercel. From GitHub connection to custom domains, everything you need to go live.
Understanding Web Hosting: A Complete Beginner's Guide
Learn web hosting from scratch. Shared, VPS, dedicated, cloud, and modern serverless options explained for beginners.
Vercel vs WordPress Hosting: Cost and Performance Comparison
Compare Vercel and traditional WordPress hosting. See real pricing, performance benchmarks, and total cost of ownership analysis.