Fundamentals 9 min read

Understanding DNS: From Queries to Caching Explained

An in‑depth guide walks through the fundamentals of the Domain Name System, explaining its role as a distributed hierarchical database, the functions of root, TLD, authoritative and local DNS servers, the recursive and iterative query processes, caching mechanisms, and practical interview insights.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Understanding DNS: From Queries to Caching Explained

The author recently interviewed at ByteDance and decided to review DNS concepts.

What is DNS

DNS (Domain Name System) is an application‑layer protocol that translates hostnames into IP addresses. It is also a distributed database composed of many DNS servers worldwide, each storing part of the hostname‑to‑IP mappings.

"DNS is a distributed database implemented by hierarchical DNS servers and an application‑layer protocol that allows hosts to query this database."

Distributed Hierarchical Database

What is distributed?

No single DNS server holds the entire Internet’s mappings; each server is responsible for a subset.

What is hierarchical?

DNS servers are organized into three types: root servers, top‑level domain (TLD) servers, and authoritative servers.

Root DNS Server

The root server manages the next level—TLD servers. Querying a root server reveals which TLD server can answer a particular domain.

Top‑Level Domain (TLD) Server

TLD servers (e.g., for .com, .cn, .org) provide the IP addresses of authoritative servers for their domains.

Authoritative DNS Server

Authoritative servers return the final hostname‑to‑IP mapping.

Local DNS Server

Local DNS servers, operated by ISPs, act as proxies for client queries and forward them into the DNS hierarchy.

Recursive and Iterative Queries

The typical lookup proceeds as follows:

The client sends a query for a.b.com to its local DNS server.

The local server forwards the query to a root server.

The root server returns the IP of the relevant TLD server.

The local server queries the TLD server.

The TLD server returns the IP of the authoritative server.

The local server queries the authoritative server.

The authoritative server returns the IP address of a.b.com.

The local server sends the IP back to the client.

In this flow, the client’s request to the local server is a recursive query, while the subsequent steps performed by the local server are iterative queries.

Both recursive and iterative modes are possible for any DNS lookup; the diagram below shows a fully recursive process without iteration.

DNS Caching

To speed up lookups, DNS servers cache received mappings for a limited time (TTL). Cached records allow most queries to bypass the root server.

Interview Reflections

The author realized that some concepts thought to be understood were not fully clear when explaining them in an interview, emphasizing the importance of solid, practical knowledge.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

cachingDNSfundamentalsDomain Name SystemIterative queryRecursive query
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.