Day 30/40 - What Is DNS (Domain Name System)
Overview
Video 30 of the Certified Kubernetes Administrator (CKA) 2024 series. A deep-dive collab with Piyush Garg (@piyushgargdev) explaining DNS fundamentals as a prerequisite for understanding Kubernetes CoreDNS.
Key Concepts Covered
1. What is DNS?
- DNS = Domain Name System / Domain Name Server
- Translates human-readable domain names (e.g., google.com) into machine-readable IP addresses
- Acts as the “phonebook of the internet”
2. Why We Need DNS
- IP addresses are hard for humans to remember
- Domains are friendly names layered on top of IPs
- Servers can change IPs dynamically (migration, scaling, failover)
- DNS abstracts away IP changes from end users
- Analogy: House name (Garg Awilla) vs full postal address
3. How DNS Works (High-Level Flow)
- User types
google.comin browser - Browser has no idea what
google.comis - Browser makes a DNS query to a DNS resolver
- DNS resolver searches its records for the domain’s IP
- IP address is returned to browser (e.g., 1.2.3.4)
- Browser forwards the HTTP request to that IP
4. DNS Caching (Multi-Level)
To avoid latency and reduce load, DNS is cached at multiple levels:
- Browser cache: First visit → DNS query; subsequent visits → cached IP
- Operating System cache: OS maintains its own DNS cache
- Router cache: Local router can cache DNS responses
- ISP cache: Internet Service Provider maintains DNS caches
- DNS server cache: Recursive resolvers cache responses with TTL
Demonstrated: Using Chrome DevTools Network tab → first visit shows “DNS lookup” timing; refresh removes DNS lookup because of browser cache.
5. Decentralized DNS Architecture
A single central DNS server would be:
- A single point of failure
- Unable to handle billions of queries
- A latency bottleneck for global users
Solution: Hierarchical, decentralized architecture.
Root Name Servers
- There are 13 root name servers (A through M)
- Hard-coded IP addresses in every OS/browser
- Each root server is actually a cluster (anycast) — multiple physical servers advertising the same IP
- Owned by different organizations: Verisign, NASA, USC, etc.
Top-Level Domain (TLD) Servers
- Root servers delegate to TLD servers based on domain extension
- Separate servers for
.com,.dev,.org,.net, etc. - Example:
piyushgarg.dev→.devTLD server handles it
Authoritative Name Servers
- TLD servers point to the domain’s authoritative name server
- This is typically the domain registrar or DNS provider (Google Domains, Cloudflare, GoDaddy)
- The authoritative server holds the actual DNS records (A, CNAME, MX, etc.)
Full Query Flow:
Browser → Local Resolver → Root Server → TLD Server (.dev) → Authoritative Server (Registrar) → IP Address
6. DNS Record Types
A Record (Address Record)
- Maps a domain directly to an IPv4 address
- Most commonly used record
- Example:
piyushgarg.dev→1.2.3.4
CNAME Record (Canonical Name / Alias)
- Maps a domain to another domain (not an IP)
- The DNS resolver then queries the target domain’s A record
- Example:
magic.piyushgarg.xyz→ CNAME →google.com→ A record →5.6.7.8 - Use case: Outsourcing to external providers (Vercel, Cloudflare Workers)
- If the provider changes their IP, your alias automatically follows
- Avoids hardcoding IPs that could change at 2 AM
- Like adding an alias; dynamic rather than static
MX Record (Mail Exchange)
- Specifies the mail server responsible for receiving email
- Used when setting up custom email (G Suite, etc.)
- Example:
[email protected]→ MX record points to SMTP server
NS Record (Name Server)
- Delegates a subdomain to a different DNS server
- Very powerful but not commonly used by everyday users
- Example:
abc.piyushgarg.xyz→ NS →ns.something.com - All subdomains under
abc.piyushgarg.xyzare resolved byns.something.com - Use case: Hosting your own DNS server
- Run a machine with port 53 (UDP) open
- Respond to DNS queries from that machine
- Create a custom DNS infrastructure
TXT Record (Text)
- Human-readable text entries
- Used for domain ownership verification
- Example: Proving you own a domain to Google Search Console or SSL providers
SRV Record (Service)
- Used for service discovery and validation
- Less commonly discussed in this video
7. Local System DNS Files (Linux/macOS)
/etc/hosts
- Local static DNS entries
- Checked before querying external DNS
- Used for local development, internal testing
- Example:
127.0.0.1 localhost 127.0.0.1 teachers-local.site - Effectively acts as a local A record
/etc/resolv.conf
- Configures which DNS resolver the system uses
- Shows the nameserver IP (e.g., local router
192.168.x.x) - Can be edited to use public DNS servers for faster resolution
8. Public DNS Resolvers
- Cloudflare DNS:
1.1.1.1(fast, privacy-focused) - Google DNS:
8.8.8.8 - Can be specified per-query with
nslookup:nslookup piyushgarg.dev 1.1.1.1 # Use Cloudflare nslookup piyushgarg.dev 8.8.8.8 # Use Google
9. DNS Propagation
- When DNS records are changed, they don’t take effect instantly
- Must propagate through the hierarchical DNS infrastructure
- Root servers → TLD servers → Resolvers → Caches all need to update
- Can take minutes to hours depending on TTL settings
10. Connection to Kubernetes
- This video is explicitly framed as a prerequisite for Kubernetes networking
- The next videos in the CKA series cover CoreDNS (Kubernetes’ cluster DNS)
- Understanding external DNS is essential before learning internal cluster DNS
Tools Demonstrated
nslookup <domain>— query DNS recordsnslookup <domain> <dns-server>— query using specific resolver- Chrome DevTools Network tab — observe DNS lookup timing
- Cloudflare DNS dashboard — add/edit DNS records (A, CNAME)
Analogy Summary
| Real World | DNS Equivalent |
|---|---|
| House name (Garg Awilla) | Domain name (google.com) |
| Full postal address | IP address (1.2.3.4) |
| Phone contact name | Domain name |
| Phone number | IP address |
Key Takeaways
- DNS translates domain names → IP addresses
- Caching happens at browser, OS, router, ISP, and DNS server levels
- DNS is decentralized via root → TLD → authoritative hierarchy
- A records map to IPs; CNAME records map to other domains (aliases)
- NS records let you delegate subdomains to custom DNS servers
/etc/hostsand/etc/resolv.confare key local DNS files on Unix systems- Cloudflare (1.1.1.1) and Google (8.8.8.8) are popular public DNS resolvers