🔍

DNS

How domain names resolve to IP addresses, DNS hierarchy, and caching

What is DNS?

The phonebook of the internet

DNS (Domain Name System) translates human-friendly domain names like www.google.com into IP addresses like 142.250.80.46 that computers use to identify each other.

Without DNS, you'd need to memorize IP addresses for every website you visit. DNS makes the internet usable by letting us use memorable names instead of numbers.

DNS Resolution Process

What happens when you type a URL

DNS Lookup Journey

Follow the query as it travels through the DNS hierarchy

Browser
Resolver
.
Root
.com
TLD
Auth NS
Step 1: User Request

You type www.example.com in your browser

Why so many steps?

This iterative process only happens on the first lookup. Results are cached at each level, so subsequent requests are much faster. A typical cached lookup takes ~1-5ms instead of ~100ms+.

DNS Hierarchy

The tree structure of domain names

DNS Tree Structure

Understanding how domains are organized hierarchically

Click on a level to learn more

How to Read a Domain Name

www . example . com . (root)
← Read right to left for hierarchy: root → TLD → domain → subdomain
🎯

Interview Insight

The trailing dot in www.example.com. represents the root. It's usually omitted but technically a fully qualified domain name (FQDN) includes it. This is why DNS is called a hierarchical system - each level delegates to the next.

DNS Record Types

Different records serve different purposes

Click on a record type to see details

Quick Reference

A/AAAA Domain → IP address
CNAME Domain → Another domain
MX Domain → Mail server
TXT Domain → Text data
🎯

Common Interview Question

"What's the difference between A and CNAME records?"
A record points directly to an IP address. CNAME points to another domain name (which then resolves to an IP). CNAMEs can't be used at the zone apex (root domain) - you need an A record there.

DNS Caching

How caching improves performance

Caching Layers

DNS responses are cached at multiple levels to reduce lookup time

Understanding TTL (Time To Live)

300
5 minutes
Good for: Dynamic IPs, quick failover
3600
1 hour
Good for: Most websites, balanced
86400
24 hours
Good for: Static sites, rarely changed
💡

Pro tip: Before a migration, lower TTL to 300 seconds 24-48 hours ahead. After the change, wait for the old TTL to expire, then raise TTL back up.

🌍

DNS Propagation

When you update DNS records, the changes don't happen instantly everywhere. Different caches expire at different times based on their TTL values.

Immediate: Your authoritative server Minutes-Hours: Most users Up to 48h: Full global propagation

Popular Public DNS Resolvers

8.8.8.8
Google
1.1.1.1
Cloudflare
9.9.9.9
Quad9
208.67.222.222
OpenDNS

Key Terms to Remember

Master these terms for technical interviews