Labs / Networking

DNS Resolution & Caching Simulator

Walk the DNS hierarchy from Browser to Root (.), TLD, and Authoritative servers. Compare cold lookups against warm Resolver and TLD caches.

New to this? There\'s a lesson below ↓
← BACK TO LABS
Resolution Hierarchy & Packet Trace
STUB
CLIENT / OS
RECURSIVE
1.1.1.1
ROOT (.)
a.root-servers
TLD
gtld-servers
AUTHORITATIVE
Zone NS
Local: 0 Resolver: 0 TLD NS: 0
Query Configuration & Metrics
TOTAL LATENCY
0 ms
HOPS
0
LOOKUP TYPE
COLD
RESOLVED IP
—
What's happening?
The lesson

DNS Hierarchy, Recursive/Iterative Queries, and Caching

How domain lookups traverse Stub, Recursive, Root (.), TLD, and Authoritative servers, and how NS referrals, glue records, and TTL caching work.

1. The DNS Namespace Hierarchy

The Domain Name System (DNS) is a distributed, hierarchical database that translates human-readable domain names (such as api.premmallah.com) into IP addresses (such as 104.21.44.18) over UDP/TCP port 53.

Instead of storing every domain on earth in one central server, the DNS namespace is organized as an inverted tree read from right to left, starting at the implicit trailing dot (.) of the root:

Server TierExample in SimulatorResponsibility
Stub ResolverCLIENT / OSBuilt into the client OS. Checks the local OS/browser cache and forwards unresolved queries to a configured Recursive Resolver.
Recursive Resolver1.1.1.1 (Cloudflare), 8.8.8.8 (Google), or ISP DNSAccepts a recursive query from the client, walks the DNS tree by following referrals, caches the results, and returns the final answer.
Root Name Server (.)a.root-servers.net (13 logical root clusters globally via Anycast)Top of the hierarchy. Does not know domain IPs; returns an NS referral (and glue IPs) for the appropriate Top-Level Domain (TLD).
TLD Name Servergtld-servers.net (.com), .edu, .orgMaintains referrals to the Authoritative Name Servers registered for every second-level domain (e.g., premmallah.com) under that TLD.
Authoritative Name Serverns1.cloudflare.com (Zone NS)The final source of truth for the domain's zone file. Returns the definitive answer (AA = 1 flag) with its configured TTL.

2. Recursive vs. Iterative Queries

A standard DNS lookup combines both query modes:

Client Stub ──[Recursive Query (RD=1)]──► Recursive Resolver
                                                │
           ┌────[Iterative Query: Root (.)]─────┼────► Referral to .com TLD
           ├────[Iterative Query: .com TLD]─────┼────► Referral to Zone NS
           └────[Iterative Query: Zone NS]──────┴────► Final A Record (104.21.44.18)
  • Recursive Query (Client → Resolver): The caller asks the server to return the complete final answer (or an error), performing all intermediate lookups on the caller's behalf.
  • Iterative Query (Resolver → Root / TLD / Authoritative): Each server replies with either the answer from its own zone or a referral (the address of the next lower server in the tree for the caller to query next). Root and TLD servers only answer iterative queries.

3. Essential DNS Resource Records & Glue Records

TypeNameWhat it stores
AIPv4 AddressMaps a hostname directly to a 32-bit IPv4 address (e.g., 104.21.44.18).
AAAAIPv6 AddressMaps a hostname directly to a 128-bit IPv6 address.
CNAMECanonical NameAliases one domain name to another target domain name (e.g., www.github.com → github.com). The resolver must then resolve the target's A record.
NSName ServerDelegates a domain zone to an authoritative name server hostname.
MX / TXTMail Exchange / TextMail servers for the domain / arbitrary verification and security text (SPF, DKIM).

Why Glue Records are needed: When the .com TLD server refers a resolver to an authoritative server whose hostname is inside the same TLD (or inside the domain itself, such as ns1.example.com for example.com), the TLD must also include the IP address of that name server in the Additional section of its response. That extra A record is called a Glue Record, preventing a circular dependency.

4. Multi-Tier Caching and TTL (Time To Live)

Every DNS record includes a TTL (Time To Live) in seconds. Test all three cache levels in the simulator:

  1. Click FLUSH ALL CACHES, then click RESOLVE DOMAIN on api.premmallah.com: performs a full 8-hop walk (96 ms at 24 ms/RTT).
  2. Click RESOLVE DOMAIN again: Local Browser/OS Cache Hit (0 ms, 0 network hops).
  3. Click CLEAR LOCAL CACHE, then click RESOLVE DOMAIN: Recursive Resolver Cache Hit (24 ms, 2 hops: Client ↔ Resolver).
  4. Click CLEAR LOCAL CACHE, switch the domain dropdown to www.github.com (also a .com domain), and click RESOLVE DOMAIN: notice the Root Server is skipped (6 hops, 72 ms) because the Resolver cached the .com TLD NS referral during step 1!

Exercises

1. Flush all caches, resolve ocw.mit.edu (.edu), then click CLEAR LOCAL CACHE and resolve cloudflare.org (.org). Does the second lookup skip the Root server? Why or why not?

Show solution
No — it takes the full 8 hops (96 ms). The first lookup cached the .edu TLD referral, whereas cloudflare.org is under .org, so the resolver must query the Root server to learn the .org TLD servers.

2. Before migrating a production web server to a new IP address at 2:00 PM tomorrow, why do engineers lower the DNS record's TTL from 86400 (24 hours) down to 60 (1 minute) at least a day in advance?

Show solution
Resolvers that cached the old IP under the 24-hour TTL will not re-query the authoritative server until that 24-hour timer expires. Lowering the TTL 24 hours ahead ensures that by migration time, every cached copy worldwide has a max lifetime of 60 seconds, so traffic cuts over to the new IP within a minute.

Quiz

When a Recursive Resolver queries a Root Name Server for api.premmallah.com, what does the Root Server return?

Why do Recursive Resolvers rarely need to query Root Name Servers in steady-state operation?

Which DNS record type aliases one hostname to another canonical hostname rather than to an IP address?

In a standard lookup, what is the difference between the Client → Resolver query and the Resolver → Root/TLD queries?