DNS Resolution¶
1. What is it? (2-3 lines)¶
DNS (Domain Name System) Resolution is the distributed hierarchical lookup process that translates human-readable domain names (e.g. api.example.com) into machine-routable IP addresses (e.g. 192.0.2.1 or 2001:db8::1).
2. Why does it exist?¶
Internet routers route network packets strictly using binary IP addresses. Since humans cannot memorize changing 32-bit (IPv4) or 128-bit (IPv6) numerical strings, DNS acts as the decentralized "phonebook of the Internet", mapping static domain names to dynamic IP locations.
3. Where is it used?¶
- Global Web Routing: Public DNS resolvers (Cloudflare
1.1.1.1, Google8.8.8.8, Route53). - Service Discovery: Kubernetes In-Cluster CoreDNS (
service-name.namespace.svc.cluster.local). - Global Traffic Management (GSLB): Geo-DNS routing, CDN Edge routing (Cloudflare, Fastly).
4. How does it work? (simple flow)¶
- Browser / Local Cache Check: OS checks local DNS cache (
/etc/hosts, browser cache). If hit, returns IP. - Recursive Resolver Query: Client queries ISP or Public Recursive Resolver (e.g.
1.1.1.1). - Root Nameserver (
.): Resolver queries Root Server \(\to\) Returns TLD Server IP for.com. - TLD Nameserver (
.com): Resolver queries TLD Server \(\to\) Returns Authoritative Nameserver IP forexample.com. - Authoritative Nameserver (
example.com): Resolver queries Authoritative Server (AWS Route53) \(\to\) Returns A/AAAA record (192.0.2.1) with TTL. - Cache & Return: Recursive Resolver caches IP for TTL duration and returns IP to client browser.
5. DNS Record Types & Functions¶
| Record | Function | Example |
|---|---|---|
| A | Maps Domain to IPv4 address | example.com -> 192.0.2.1 |
| AAAA | Maps Domain to IPv6 address | example.com -> 2001:db8::1 |
| CNAME | Canonical Name (Alias domain to another domain) | www.example.com -> example.com |
| ALIAS / ANAME | Virtual A-record at Zone Apex (Root domain alias) | example.com -> d123.cloudfront.net |
| MX | Mail Exchange server routing | example.com -> mail.example.com |
| TXT | Arbitrary text metadata (SPF, DKIM, Domain Verification) | v=spf1 include:_spf.google.com ~all |
6. Limitations¶
- Stale DNS Caching: OS, JVM, and intermediate ISP resolvers ignore short TTLs, causing delayed failover during migrations.
- DNS Amplification Attacks: UDP-based DNS query spoofing used for large-scale DDoS attacks.
7. Common interview questions (10)¶
- Walk through the complete step-by-step DNS resolution process for
api.example.com. - What is the difference between a Recursive DNS Resolver and an Authoritative DNS Nameserver?
- How does Geo-DNS (Latency-based routing) route users to the nearest AWS datacenter?
- What is the CNAME Zone Apex restriction and how do ALIAS / ANAME records solve it?
- How does Kubernetes CoreDNS resolve in-cluster microservice names (
payment.default.svc.cluster.local)? - How does JVM DNS caching (
networkaddress.cache.ttl) cause severe microservice outage risks? - What is DNSSEC and how does it prevent DNS Cache Poisoning / Spoofing?
- Why is UDP port 53 used for DNS queries, and when does DNS fall back to TCP?
- How does Anycast IP routing enable high-availability DNS networks (like Cloudflare
1.1.1.1)? - How do EDNS Client Subnet (ECS) extensions improve CDN edge server routing accuracy?
8. Common misconceptions¶
- Misconception: CNAME records can be set on root domains (
example.com). Fact: RFC specs forbid CNAME at zone apex because CNAME overrides all other record types (MX, TXT). Use ALIAS/ANAME records instead. - Misconception: Lowering DNS TTL to 0s updates all global users instantaneously. Fact: Many ISPs and OS resolvers enforce minimum hardcoded cache floors (e.g. 300s), ignoring 0s TTLs.
9. Related Concepts¶
10. 30-second cheat sheet¶
- Hierarchy: Browser Cache \(\to\) OS Cache \(\to\) Recursive Resolver \(\to\) Root (
.) \(\to\) TLD (.com) \(\to\) Authoritative Server. - Record Rules: A = IPv4; AAAA = IPv6; CNAME = Alias (Non-root); ALIAS = Root apex alias.
- K8s DNS: CoreDNS handles
service-name.namespace.svc.cluster.local. - Top Pitfall: Set
networkaddress.cache.ttl=30in Java JVM to prevent permanent stale IP caching!