20 min read DNS & Name Resolution Lesson 6 of 13
Part 2 — Packets, Routing & Transmission Protocols

Lesson 06 — How DNS Finds Websites: Domain Name System Explained

The global phone book of the Internet: Translating human names to machine IP addresses through a distributed hierarchy

What We Will Learn in This Lesson

By the end of this lesson, you will master every core component of how the Internet resolves names into operational network addresses:

  • What a Domain Name is and why humans require it
  • What DNS is and why it is more than just a phone book
  • The role of a Recursive DNS Resolver
  • Differences between Root, TLD, and Authoritative servers
  • Step-by-step resolution of google.com or youtube.com
  • DNS Caching and TTL (Time To Live) principles
  • DNS Records: A, AAAA, CNAME, MX, TXT, and NS
  • How browsers and operating systems find cached DNS data
  • The power of the local Hosts file for overrides
  • Why domain changes take time to propagate worldwide
  • DNS Security: Spoofing, Cache Poisoning, DNSSEC, DoH, and DoT

1 Starting with a Problem

In our earlier lessons, we learned a fundamental truth: Computers require numerical IP addresses to route packets and communicate across networks.

Imagine an arbitrary web server on the public Internet with the following IPv4 address:

203.0.113.80

Routers, switches, and operating system network stacks excel at handling these 32-bit binary integers. But imagine if your daily Internet browsing required memorizing instructions like these:

To watch YouTube: Open your browser and type 142.250.190.46
To search Google: Remember the number 172.217.16.206
To view GitHub: Type 140.82.121.4

For human beings, memorizing arbitrary numerical strings for dozens or hundreds of websites is completely inconvenient and impractical. Humans remember meaningful names and words: youtube.com, google.com, github.com.

How does a computer convert these human-readable names into machine-routable IP addresses in milliseconds?
The Answer: DNS (Domain Name System)

2 What is DNS?

DNS stands for Domain Name System.

DNS is a globally distributed, hierarchical naming database that translates human-readable names (such as domain names) into network-routable metadata (such as IP addresses).

Domain Name (youtube.com) → DNS Resolution → IP Address (142.250.190.46)

It is commonly called "The phone book of the Internet." Just as your phone contact list lets you tap a friend's name instead of dialing their 11-digit phone number, DNS allows your browser to look up the server's numeric IP behind any domain name.

Caution: While the phone book analogy is a great starting mental model, DNS is much more than a simple phone book. DNS does not merely return IP addresses; it publishes mail server routing (MX), domain ownership verifications (TXT), hostname aliases (CNAME), and cryptographic identity keys (DNSSEC).

3 What is a Domain Name?

Consider a typical domain name: www.example.com.

Domain names are structured in a strict hierarchy, organized into discrete labels delimited by dots. Reading from right to left:

www.example.com.
Subdomain
www, api, blog, mail
Second-Level (SLD)
Registered name (example)
Top-Level Domain (TLD)
.com, .org, .net, .bd
Root Domain (.)
The implicit dot at root

Each dot represents a level in the DNS tree. As you travel from right to left, the scope narrows from the global root zone down to an individual host within a specific domain.

4 Are a Domain Name and a Website the Same?

No! Beginners often conflate these two concepts, but they are completely different entities:

Domain Name (The Signpost / Address)

A human-readable label or registered identity (e.g., byteion.com). It does not execute code, store files, or render visual UI on its own.

Website (The House / Application)

The live software service or web application running on an active server. It consists of HTML, CSS, JavaScript, backend processes, and databases.

A domain name points to a website's hosting server, but DNS does not make a website. DNS simply handles the lookup and returns the addressing metadata required to find it.

5 You Typed youtube.com in Your Browser

Now the real journey begins. You type youtube.com into your browser's address bar and hit Enter.

The browser immediately faces an obstacle: "What IP address should I open a TCP connection to? Which network destination hosts this service?"

1. youtube.com → 2. DNS Lookup → 3. Destination IP → 4. TCP Handshake → 5. HTTP / HTTPS Data

Until DNS resolution completes, no HTTP packets can be sent. Your operating system's networking stack must resolve this name into an IP address.

6 Do We Immediately Go to the Root Servers?

Not at all! This is where DNS's most critical performance optimization comes in: Caching.

If you opened YouTube just two minutes ago, your computer already knows the IP. It would be tremendously inefficient to traverse global root servers on every keystroke.

Your system checks several layers of local caches before transmitting queries over the Internet:

1. Browser Cache Chrome or Firefox's internal in-memory DNS cache (Fastest, 0 ms latency)
2. Operating System Cache Windows, macOS, or Linux OS DNS Client caching daemon
3. Local Gateway / Wi-Fi Router Home Wi-Fi router's DNS proxy cache
4. Recursive DNS Resolver Cache Your ISP or public DNS provider's (e.g. 1.1.1.1) massive shared cache

If a valid record is found in any of these caches, the lookup finishes immediately!

7 What is a Recursive DNS Resolver?

Your individual laptop or smartphone does not wander across dozens of authoritative name servers on its own. Instead, it delegates the search to a specialized intermediary: the Recursive DNS Resolver.

The Personal Assistant Analogy

Think of the recursive resolver as your personal research assistant. You hand it an assignment: "Find the IP address for youtube.com." You can relax while the assistant travels the world, interrogates root servers, consults TLD registries, contacts authoritative name servers, compiles the final answer, and delivers it to your desk.

By default, your Internet Service Provider (ISP) configures a resolver via DHCP. Alternatively, you can configure high-performance public resolvers such as Cloudflare (1.1.1.1), Google Public DNS (8.8.8.8), or Quad9 (9.9.9.9).

8 The DNS Lookup Hierarchy

When the resolver's cache is empty, it must resolve the domain iteratively through the DNS hierarchy:

1. Root DNS Server (.)
↓ points to
2. TLD DNS Server (.com)
↓ points to
3. Authoritative DNS Server

9 What are Root DNS Servers?

At the pinnacle of the DNS pyramid sits the Root Zone, represented by the trailing dot in fully qualified domain names (example.com.).

The resolver asks the root server: "Where can I find the IP address for youtube.com?"

Root servers do not maintain individual website records. Instead, they respond:

"I do not know the IP address of youtube.com. However, because its extension is '.com', you must ask the .com TLD servers. Here is the list of name server IPs for the .com registry!"

Engineering Fact: There are 13 logical root server IP addresses (labeled a.root-servers.net through m.root-servers.net). However, using Anycast Routing, over 1,700 redundant, high-capacity physical servers around the globe answer queries directed to these 13 IP addresses.

10 What is a TLD?

TLD stands for Top-Level Domain. It is the final label of a domain name:

gTLD (Generic Top-Level Domains)
.com, .org, .net, .edu, .gov, .io, .ai
ccTLD (Country-Code Top-Level Domains)
.bd (Bangladesh), .uk (United Kingdom), .jp (Japan), .de (Germany)

Equipped with the root referral, the resolver queries the .com TLD Registry Server: "Where is the authoritative name server for youtube.com?"

The TLD server replies: "Google has delegated youtube.com to its authoritative name servers (e.g., ns1.google.com). Here are their IP addresses."

11 What is an Authoritative DNS Server?

This brings us to the definitive source of truth in DNS: the Authoritative DNS Server.

This server holds the definitive Zone File and official records configured directly by the domain's owner or DNS administrator.

Authoritative DNS Transaction:
Resolver: "What is the A record (IPv4 address) for youtube.com?"
→ Authoritative Server: "youtube.com IN A 142.250.190.46 (TTL: 300 seconds)"

The resolver receives the exact, canonical answer.

12 The Complete DNS Resolution Journey

When no cached answers exist, the complete sequence of events unfolds as follows:

1 Your Computer → Queries the recursive resolver ("Give me the IP for youtube.com")
2 Resolver → Queries a Root Server (.)
3 Root Server → Returns referral to .com TLD servers
4 Resolver → Queries the .com TLD server
5 TLD Server → Returns referral to authoritative name servers (ns1.google.com)
6 Resolver → Queries the Authoritative Name Server
7 Authoritative Server → Returns the final IP address: 142.250.190.46
8 Resolver → Caches the IP and returns the answer to your machine
9 Your Computer → Establishes a direct TCP connection to the destination IP!

13 A Crucial Technical Reality

Many tutorials simplify DNS as merely: "DNS converts domain names into IP addresses."

While helpful for beginners, this understates its true engineering power:

DNS is a distributed naming database, not merely a domain-to-IP converter.

DNS stores, verifies, and distributes diverse types of structured data called Resource Records. Let's inspect each standard record type.

14 What is an A Record?

The most common DNS record is the A Record (Address Record).

It maps a hostname directly to a 32-bit dotted-decimal IPv4 address:

example.com. IN A 192.0.2.10

15 What is an AAAA Record?

For 128-bit IPv6 addresses, DNS uses the AAAA Record (pronounced "Quad-A Record").

Because an IPv6 address is four times larger than a 32-bit IPv4 address, the record is designated with four 'A's:

example.com. IN AAAA 2001:db8:85a3::8a2e:370:7334

Rule of thumb: A → IPv4 and AAAA → IPv6.

16 What is a CNAME Record?

CNAME stands for Canonical Name. Instead of resolving to an IP address, a CNAME record points one hostname as an alias to another hostname.

www.example.com. IN CNAME example.com.
↓ The client then resolves the canonical target's A record: 192.0.2.10

Advantage: When you change your hosting server's IP address, you only need to update the root domain's A record; all CNAME aliases (such as www, api, or blog) follow automatically.

17 What is an MX Record?

MX stands for Mail Exchange.

When an email is sent to user@example.com, the sending email server queries DNS: "Which mail server receives emails for @example.com?"

example.com. IN MX 10 mail.google.com.

The number '10' represents preference or priority (lower numbers indicate higher priority). This proves that DNS underpins not just the Web, but the entire global email routing system.

18 What is a TXT Record?

A TXT Record allows domain administrators to attach arbitrary human- and machine-readable text to a domain.

In the modern web, it is fundamental for domain ownership verification and anti-spam authentication:

SPF (Sender Policy Framework):
"v=spf1 include:_spf.google.com ~all"
Specifies which mail servers are legitimately authorized to send email on behalf of your domain.
Domain Ownership Verification:
"google-site-verification=AbCdEf12345"
Proves to services like Google Search Console or Cloudflare that you own the domain.

19 DNS Records Summary (Cheat Sheet)

Record Type Full Name Primary Role Real-World Example
A Address Maps hostname to 32-bit IPv4 address 192.0.2.1
AAAA IPv6 Address Maps hostname to 128-bit IPv6 address 2001:db8::1
CNAME Canonical Name Creates an alias pointing to another hostname app.byteion.com
MX Mail Exchange Directs inbound email to designated mail servers with priority mail.example.com (Priority 10)
TXT Text Stores arbitrary text, SPF policy, and verification tokens "v=spf1 -all"
NS Name Server Delegates zone management to authoritative name servers ns1.byteion.com

20 What is DNS Cache?

Imagine if billions of Internet users had to query the root and authoritative name servers for every single click on Google, YouTube, or Wikipedia:

  • • Global Internet backbones would choke on repetitive DNS query packets.
  • • Root and authoritative servers would instantly crash under DDoS-scale traffic.
  • • Every website load would suffer an extra 50–300 milliseconds of latency.

Caching stores the resolved record locally. Subsequent requests for the same hostname are answered in zero milliseconds without touching the external network.

21 What is TTL (Time To Live)?

While caching improves speed, records cannot remain cached indefinitely.

Today, your website might run on server 'A' (IP 203.0.113.1). Tomorrow, you migrate to a larger server 'B' (IP 198.51.100.50). If client machines cached the old address forever, users would never reach your new server!

Every DNS record specifies a lifespan in seconds known as TTL (Time To Live).

byteion.com.   300   IN A   104.21.48.91
Here, the TTL is 300 seconds (5 minutes). After 300 seconds, caches must discard this entry and query upstream.

22 What if TTL is Low?

Suppose you configure an aggressive TTL of just 60 seconds:

Advantages:
Changes propagate rapidly worldwide within a minute. Excellent during migrations and rapid failovers.
Trade-offs:
Caches expire rapidly, placing heavy repeated query loads on authoritative servers and slightly increasing client latency.

23 What if TTL is High?

Suppose you configure a relaxed TTL of 86,400 seconds (24 hours):

Advantages:
Minimal query load on authoritative servers. Clients enjoy near-instant local cache hits.
Trade-offs:
If you change your server IP, visitors will continue hitting the old IP for up to 24 hours until their caches expire.

24 Does the Browser Always Query DNS Servers?

No! Resolution follows a strict order of precedence:

Step 1: Checks the local Browser Cache.
Step 2: Checks the operating system's local Hosts File for overrides!
Step 3: Checks the OS DNS Client Cache (e.g., Windows DNS Client or systemd-resolved).
Step 4: Queries the local Gateway / Wi-Fi Router cache.
Step 5: Only if all local caches miss does it transmit a packet to the upstream Recursive Resolver.

25 What is the Hosts File?

Before the invention of DNS in the early 1980s, the entire ARPANET directory was maintained in a single plain text file: HOSTS.TXT. Every modern OS retains this legacy mechanism:

Windows: C:\Windows\System32\drivers\etc\hosts
macOS & Linux: /etc/hosts

You can manually bind any hostname to any IP address directly in this file:

127.0.0.1   mytestsite.local
203.0.113.80   example.com

Web developers frequently use the hosts file to test staging environments before pointing live production DNS to a new server.

26 Why Domain Changes Don't Update Instantly Worldwide

A universal rite of passage for web developers: You update your DNS A record to a new server, and while you see the new website immediately, a customer across the world still sees the old site!

This is known as DNS Propagation Delay.

The Cause: Thousands of ISPs, public resolvers, and routers around the world have already cached your previous IP address. Each resolver has its own countdown timer based on your previous TTL. Resolvers whose caches expire quickly adopt the new IP immediately, while others must wait out their remaining TTL duration.

27 Recursive Resolver vs. Authoritative Server

Recursive Resolver (The Searcher)
  • • Accepts queries from client devices.
  • • Does not own zone files of its own.
  • • Relies on caching to accelerate queries.
  • • Examples: Cloudflare (1.1.1.1), Google (8.8.8.8).
Authoritative Server (The Authority)
  • • Holds the master Zone File and definitive records.
  • • Does not wander; answers authoritatively for its zone.
  • • Configured directly by the domain administrator.
  • • Examples: AWS Route 53, Cloudflare DNS, Cloudns.

28 Root Server vs. TLD Server vs. Authoritative Server

Reviewing the three primary tiers side-by-side clarifies their distinct responsibilities:

Root Server: Provides direction toward the appropriate TLD (.com, .org) registry.
TLD Server: Points to the authoritative name servers designated for that specific domain.
Authoritative: Supplies the definitive A, AAAA, MX, or CNAME records containing actual IP addresses.

29 A Cinematic Trace of a Full DNS Lookup

Tracing the complete lifecycle when you request www.example.com:

1. Browser & OS cache inspected Cache Miss!
2. UDP port 53 query sent to Resolver (1.1.1.1) Query Dispatched
3. Query forwarded to Root Server (a.root-servers.net) Referral: .com TLD
4. Query forwarded to .com TLD Server (a.gtld-servers.net) Referral: ns1.example.com
5. Query forwarded to Authoritative Server (ns1.example.com) Answer: 192.0.2.10 (TTL 300)
6. Resolver caches record and returns IP to your client Resolved in 18ms!

30 The Vital Bridge Between DNS and HTTP

This insight connects DNS directly to our upcoming study of web protocols:

youtube.com → DNS (Address Discovery) → IP: 142.250.190.46 → TCP Handshake (Port 443) → HTTP / HTTPS GET → Web Response

DNS discovers the destination address. Once the connection is established, HTTP serves as the application-level dialogue between browser and server.

31 Is DNS the Only Naming System on the Internet?

While DNS is the standard for the public Internet, other naming systems serve specific environments:

  • • mDNS (Multicast DNS): Resolves .local hostnames on local subnets without a dedicated server (e.g., Apple Bonjour, IoT smart lights, local printers).
  • • NetBIOS / WINS: Legacy Microsoft naming systems for local Windows networks.
  • • Internal Service Registries (Consul, Eureka, Kubernetes CoreDNS): Internal service discovery across dynamic microservice containers.

32 Does DNS Only Return IPv4 Addresses?

No! DNS simultaneously returns IPv4 addresses via A Records and IPv6 addresses via AAAA Records. Modern client operating systems issue parallel lookups (the Happy Eyeballs algorithm, RFC 8305) and connect to whichever protocol stack responds fastest.

33 DNS Security: Spoofing, DNSSEC, DoT, and DoH

When DNS was specified in 1983 (RFC 882), network security and encryption were non-existent considerations. Traditional DNS queries travel as unencrypted plaintext UDP packets, giving rise to serious vulnerabilities:

DNS Spoofing & Cache Poisoning
An attacker injects forged IP responses into a resolver's cache, redirecting banking traffic to malicious clones.
Plaintext Snooping & Censorship
ISPs and intermediate routers can inspect every domain you query, profiling user behavior or blocking specific websites.

To address these vulnerabilities, modern networking relies on three security innovations:

DNSSEC (DNS Security Extensions): Uses cryptographic digital signatures to verify that DNS responses genuinely originate from the authenticated zone owner and have not been tampered with.
DoT (DNS over TLS - Port 853): Encrypts all DNS queries in transit using standard TLS encryption, preventing eavesdropping between the client and resolver.
DoH (DNS over HTTPS - Port 443): Disguises DNS queries inside standard encrypted HTTPS traffic, preventing network providers from snooping or censoring DNS queries.

34 What We Have Learned (Key Takeaways)

Domain Name: A human-friendly alias designed for easy recall (e.g., byteion.com).
DNS: The distributed naming database mapping domain names to IP addresses and operational records.
Resolver: Your client's assistant querying the global hierarchy on your behalf.
Root & TLD: Direct queries toward top-level extensions (.com) and authoritative servers.
Authoritative: The definitive keeper of the domain's real zone file and official records.
TTL & Cache: The lifespan and distributed caching system protecting the Internet from traffic overload.

35 The Complete Internet Communication Pipeline

The isolated concepts we've explored across Course 08 now lock together into a cohesive architecture:

1. You type a domain in the browser: youtube.com
↓
2. DNS: "Where is this host on the network?" → 142.250.190.46
↓
3. Port: "Which server application receives this traffic?" → Port 443 (HTTPS)
↓
4. TCP Handshake: "SYN → SYN-ACK → ACK establishes reliable byte-stream"
↓
5. Packet & Routing: "Routers inspect IP headers and forward hop-by-hop"
↓
6. Server: "Packets delivered! Let's speak application-level HTTP!"

36 What's Next in Lesson 07?

Our computer now knows how to locate any server on Earth and establish a reliable transport socket. But how do browsers and servers actually talk to exchange webpages, images, and videos?

Coming Up in Lesson 07: HTTP — The Language of the Web

In Lesson 7, we unpack how web clients construct requests, the difference between GET and POST, the meaning of status codes like 200 OK, 404 Not Found, and 500 Server Error, and how headers and cookies bring stateless web protocols to life.

Hands-On Laboratory

Interactive DNS Simulator & Sandbox

Trace hierarchical recursive resolution step-by-step, inspect DNS zone records, and observe global propagation

1. Client
2. Recursive Resolver
3. Root Server (.)
4. TLD Server
5. Authoritative
Network Status: Ready (Idle) Latency: 0 ms
Client ready to dispatch query
Click "Next Step" or "Auto Play" to begin
// DNS Protocol Trace Terminal
> System initialized. Awaiting user query...

Knowledge Check Quiz

Test your mastery of DNS architecture and record resolution:

1. Which server type is the definitive, authoritative owner holding the domain's real Zone File and official records?

2. Which record type is used to alias a subdomain (such as www.example.com) to point to another canonical hostname rather than directly to an IP address?

3. Why does updating a domain's IP address not take effect simultaneously for all users across the world?