Understanding DNS workflow

Monday, November 18, 2024

Understanding DNS workflow

Table of Contents

DNS (Domain Name System)

DNS (Domain Name System) is one of the key components responsible for interacting with websites in the most human-readable way possible.

We use names or characters to search the web, like youtube.com, but computers do not understand human terms. There is a need to convert these into machine-readable forms, i.e., the IP addresses.

DNS just does that work!


Behind the scenes, the Domain Name System (DNS) acts as the internet’s phonebook, converting human-readable domain names into machine-friendly IP addresses. Let’s break this down step-by-step, based on the flow shown in the accompanying diagram.

How Does DNS Work?

The flowchart below provides an overview of how a typical DNS flow works:

dns-flow

Here is a brief description of the flowchart:

  1. Cache Memory: The Shortcut to Speed

    Before making any external queries, your device (or local resolver) checks cache memory.

    • If the requested domain's IP address is already stored in the cache (called a HIT), the process ends here, and the IP is returned to your browser.
    • If the cache doesn't contain the address (a MISS), the resolver proceeds to the next step.

    Why Cache Matters: Caching ensures faster responses for commonly visited sites, saving bandwidth and reducing latency.

  2. The Resolver: Your Internet Service Provider’s Workhorse

    The resolver (typically managed by your ISP) is responsible for handling your DNS query when the cache comes up empty. It starts by asking higher-level servers for help, beginning with the Root Servers.

  3. Root Servers: The Internet's Top-Tier Guides

    The resolver sends a query to one of the Root DNS Servers. These servers don’t know the exact IP address of www.youtube.com, but they do know which Top-Level Domain (TLD) Server to ask.
    In this case, the root server would direct the resolver to the .com TLD server, since YouTube’s domain ends with .com.

    Fun Fact: There are only 13 logical root servers (mirrored worldwide) managing billions of queries daily.
    Root-server-lists

    src

  4. TLD Servers: Narrowing It Down

    Once the resolver contacts the TLD server for .com, it receives a more specific answer: the location of the Authoritative Name Server for youtube.com.
    This server holds the final piece of the puzzle—the exact IP address of www.youtube.com.

  5. Authoritative Name Servers: The Final Answer

    The resolver queries the authoritative name server for the IP address of www.youtube.com. Finally, the IP address (e.g., 172.217.164.110) is returned to the resolver.

  6. Back to Cache Memory

    Before passing the IP address to your browser, the resolver stores it in its cache. This ensures that subsequent requests for www.youtube.com (or related domains) will be much faster.

Why Does This Process Matter?

This layered query system ensures two key things:

  • Efficiency: By caching frequently requested domains, DNS minimizes unnecessary queries and improves performance.
  • Scalability: The hierarchical structure spreads the load across multiple servers, ensuring the DNS system can handle billions of users worldwide.

A Fun Analogy: I Know a Guy Who Knows a Guy

Imagine you’re looking for the address of a popular restaurant in a new city. Here’s how DNS compares:

  1. You ask a friend (your cache)—if they know the address, you’re done!
  2. If not, your friend asks a local guide (the resolver).
  3. The guide refers to the central city office (root server) for help.
  4. The city office directs the guide to the restaurant chain’s regional office (TLD server).
  5. Finally, the regional office gives the exact address from their records (authoritative server).

This layered approach ensures that even if one source doesn’t know the answer, another can point in the right direction.


Key Takeaways

  • DNS is essential for converting domain names into IP addresses.
  • Caching improves speed and reduces repeated queries.
  • The resolver works step-by-step, querying root, TLD, and authoritative servers.
  • The hierarchical structure makes DNS scalable and reliable for billions of users.