🌍 How DNS Resolution Actually Works (Step-by-Step)¶
When a user enters:
1️⃣ Browser checks local cache¶
2️⃣ OS checks system DNS cache¶
3️⃣ Router cache¶
4️⃣ Recursive Resolver (ISP / Public DNS)¶
5️⃣ Root Nameserver¶
6️⃣ TLD Nameserver (.com)¶
7️⃣ Authoritative Nameserver¶
8️⃣ Returns IP address¶
Then browser connects to that IP.
🔥 Important DNS Record Types (DevOps Must Know)¶
1️⃣ A Record¶
Maps domain → IPv4 address
Used For:¶
- Web servers
- Load balancer IP
- Static server mapping
DevOps Debug:¶
If site not loading:
Check returned IP.
2️⃣ AAAA Record¶
Maps domain → IPv6 address
Important when infrastructure supports IPv6.
3️⃣ CNAME Record¶
Maps one domain → another domain
Not IP → Domain to domain.
Rules:¶
- Cannot exist with other records at same hostname.
- Not allowed at root (in pure DNS standard).
4️⃣ MX Record (Mail Exchange)¶
Defines mail server.
Lower number = higher priority.
5️⃣ TXT Record¶
Stores text data.
Used for:
- Domain verification
- Email SPF
- DKIM
- DMARC
- Security proofs
Example:
6️⃣ NS Record (Nameserver)¶
Defines who controls DNS for domain.
Changing NS = moving DNS control.
7️⃣ SOA Record (Start of Authority)¶
Contains:
- Primary nameserver
- Email of admin
- Serial number
- Refresh time
- Retry time
- Expiry
- TTL
Important for DNS replication.
8️⃣ SRV Record¶
Defines service location with port.
Example:
Used in:
- SIP
- LDAP
- Kubernetes
- Internal services
9️⃣ CAA Record¶
Controls which Certificate Authorities can issue SSL certificates.
Example:
Security-focused record.
🔥 DNS TTL (Time To Live)¶
Every record has TTL:
Meaning cache for 5 minutes.
DevOps Strategy:¶
Before migration:
- Lower TTL to 60 seconds
- Perform change
- Raise TTL back
🔥 DNS Propagation Reality¶
Propagation is not magic.
It depends on:
- TTL
- Resolver cache
- ISP caching
It is caching delay, not "internet propagation".
🔥 Common Production DNS Issues¶
🚨 1. Wrong IP in A record¶
Site unreachable.
🚨 2. Missing AAAA record but server supports IPv6¶
Partial users can’t access site.
🚨 3. CNAME + A record conflict¶
DNS resolution failure.
🚨 4. High TTL during migration¶
Users hit old server.
🚨 5. MX misconfiguration¶
Emails stop working.
🔥 DevOps Debug Commands¶
Check A record¶
Check specific record type¶
Trace full resolution path¶
Shows root → TLD → authoritative flow.
Check from another DNS resolver¶
Check DNS quickly¶
🔥 Advanced DevOps DNS Concepts¶
🔹 Split-Horizon DNS¶
Internal users resolve to private IP External users resolve to public IP
Used in:
- VPC internal services
- Hybrid cloud
🔹 DNS Load Balancing¶
Multiple A records:
DNS rotates responses.
Not true health-aware load balancing.
🔹 Failover Strategy¶
Primary A record Secondary A record Low TTL for faster failover
🔹 DNS and CDN Interaction¶
When using reverse proxy:
- DNS points to proxy
- Proxy points to origin
Understanding this is critical.
🔥 1️⃣ Difference Between A Record and CNAME¶
✅ A Record¶
- Maps a domain → IPv4 address
- Direct resolution
- Faster lookup (1 step)
Example:
✅ CNAME Record¶
- Maps a domain → another domain
- Indirect resolution (extra DNS lookup)
Example:
🔥 Key Differences¶
| A Record | CNAME |
|---|---|
| Points to IP | Points to domain |
| Faster resolution | Extra DNS lookup |
| Can exist with other records | Cannot coexist with other records |
| Used at root domain | Not allowed at root (standard DNS) |
💬 Interview Answer (Short Version)¶
An A record maps a domain directly to an IP address, while a CNAME maps a domain to another domain name. CNAME adds an extra resolution step and cannot coexist with other record types at the same hostname.
🔥 2️⃣ Why Can't Root Domain Have CNAME?¶
Root domain (example.com) must contain:
- NS record
- SOA record
DNS standards say:
A CNAME record cannot exist with any other record at the same name.
Since root must already have NS and SOA, adding CNAME would violate DNS rules.
That’s why:
- Subdomains → can use CNAME
- Root domain → must use A or ALIAS/ANAME (provider workaround)
💬 Interview Answer¶
Because the root domain must contain SOA and NS records, and DNS standards do not allow a CNAME to coexist with other record types at the same name.
🔥 3️⃣ What Happens When TTL is High?¶
TTL = Time To Live (cache duration in seconds)
Example:
Effects:
- DNS changes propagate slowly
- Users may hit old server
- Hard to rollback quickly
- Failover becomes slow
🔥 DevOps Impact¶
If migrating servers:
- High TTL = downtime risk
- Low TTL (60–300 seconds) = safer migration
💬 Interview Answer¶
High TTL causes DNS responses to be cached longer, making infrastructure changes slow to propagate and reducing flexibility during migrations or failover events.
🔥 4️⃣ How to Migrate Server Without Downtime?¶
This is a very important DevOps scenario.
✅ Step-by-Step Zero Downtime Migration¶
Step 1 – Lower TTL¶
Reduce TTL from:
Wait for old TTL to expire.
Step 2 – Prepare New Server¶
- Deploy application
- Test internally
- Sync database
- Verify SSL
Step 3 – Switch A Record¶
Change IP to new server.
Because TTL is low:
- Most users switch within 1–5 minutes.
Step 4 – Monitor Logs¶
Watch:
- Error rates
- CPU
- Traffic
- 5xx errors
Step 5 – Increase TTL Again¶
After stable:
🔥 Advanced Approach¶
For large systems:
- Blue-Green deployment
- Load balancer switch
- Gradual traffic shift
💬 Interview Answer¶
Lower TTL in advance, prepare and test the new server, update DNS to point to the new IP, monitor traffic, then increase TTL once stable. This ensures minimal caching delay and avoids downtime.
🔥 5️⃣ What Is SOA Serial Used For?¶
SOA = Start of Authority
It contains:
- Primary nameserver
- Admin email
- Serial number
- Refresh interval
- Retry interval
- Expiry time
🔥 Serial Number Purpose¶
It tells secondary DNS servers:
“Zone file has changed.”
If serial increases:
- Secondary servers pull updated records.
If serial doesn’t change:
- No update happens.
Example Serial Format¶
Common format:
💬 Interview Answer¶
The SOA serial number is used for zone versioning. When the serial increases, secondary DNS servers know the zone file has been updated and synchronize the changes.
🔥 Bonus: Strong DevOps-Level Summary¶
If interviewer asks all together:
- A record → Direct IP mapping
- CNAME → Domain alias
- Root can't use CNAME → Because SOA and NS must coexist
- High TTL → Slower propagation, risky for migration
- Zero downtime → Lower TTL, switch after preparation
- SOA serial → Zone replication control