๐Ÿ“˜ Visual Posts About Contact
Explore ๐Ÿ“‹ Cheat Sheets โœ๏ธ Practice ๐ŸŽฎ Games ๐ŸŽฌ Simulations ๐Ÿƒ Flashcards ๐ŸŽฏ Interactive Layers ๐Ÿ“– Storytelling
๐Ÿ’œ Support my site

Master the DNA of the Internet

Stop guessing how domains work. This comprehensive guide takes you from zero to heroโ€”explaining protocols, hierarchy, and security with interactive visuals.

Start Learning ↓
USER Laptop RESOLVER ISP / Public DNS . ROOT .com TLD google AUTH 1 Query 2 Referral 4 6 IP: 142... 8 Answer

01 The Foundation

DNS (Domain Name System) is the decentralized naming system for the internet. It acts as the "phonebook" that translates human-readable domain names into machine-readable IP addresses.

Analogy: The Contacts App.
You don't memorize your friend's phone number. You tap "Alex" (the name), and your phone calls +1-555-0199 (the number). DNS is the contact list for the entire Internet.

Memorability

Humans remember words (shekharit.com) better than random numbers (104.21.55.2).

Flexibility

You can change your server (IP) without changing your brand name (Domain). The user never knows.

Stability

DNS provides redundancy. One name can map to multiple IPs (Load Balancing) to prevent crashes.

Historical Context: Before DNS

In the 1970s (ARPANET era), there was no DNS. Every computer had to manually download a single text file called HOSTS.TXT from a central server at Stanford. As the network grew, this became impossible to manage. DNS was invented in 1983 to solve this scalability problem.

Deep Dive: Transport Protocols (UDP, TCP, DoH, QUIC)

DNS isn't just one protocol. It adapts based on the situation:

  • UDP Port 53 (The Standard): Used for 95% of queries. It's connectionless and fast. Low overhead, but limited space (512 bytes).
  • TCP Port 53 (The Heavy Lifter): Used when the answer is too big for a postcard (e.g., DNSSEC signatures) or for Zone Transfers between servers.
  • DoH / DoT (Privacy):
    DNS over HTTPS (443): Hides DNS queries inside normal web traffic so ISPs can't snoop.
    DNS over TLS (853): Encrypts the specific DNS channel.
  • 2026 Standard: DNS over QUIC (DoQ)
    Uses HTTP/3 (QUIC) on UDP port 853 or 443. It combines the speed of UDP with the security of TLS, solving the "Head-of-Line Blocking" issue found in TCP.

02 Domain Anatomy

A domain name is a hierarchical pointer into a distributed database. While humans read it as a phrase, the DNS protocol treats it as a sequence of labels processed from Right to Left.

THE FQDN STRING . ROOT com Top Level . google 2nd Level . maps 3rd Level . PARSING DIRECTION THE ACTUAL STRUCTURE . Root Zone com TLD Zone google Domain Zone maps Host / Record
Critical Distinction: Label vs. Domain Name
In google.com, "google" is the Label (the name of the node). "google.com" is the Domain Name (the full path to that node).

1. The Root (.)

The absolute top of the tree. In the DNS protocol, it is represented by a Null Label (a zero-length string). We write it as a dot (.).

2. Top-Level Domain (TLD)

Managed by Registries.
โ€ข gTLD: Generic (.com, .net).
โ€ข ccTLD: Country Code (.in, .jp, .uk).
โ€ข sTLD: Sponsored (.edu, .gov).

3. Second-Level Domain (SLD)

The specific label you register with a Registrar (e.g., google). Combined with the TLD, it forms your Zone of Authority.

4. Subdomain

A domain that is part of a larger domain. maps.google.com is a subdomain of google.com. It adds another layer of specificity.

Deep Dive: What is a Fully Qualified Domain Name (FQDN)?

An FQDN specifies the exact location of a host in the DNS tree hierarchy. It is absolute.

  • The Silent Dot: A true FQDN must end with a dot: mail.google.com.
  • Why don't we type it? Web browsers add the dot for you automatically behind the scenes (in the resolver library).
  • Ambiguity: Without the dot, a system might treat the name as relative. If you are on a corporate network corp.local and type server1, the computer tries server1.corp.local. If you type server1., it looks for a TLD named server1.
Deep Dive: IDN, Punycode & Standards (RFC 1035)

DNS is governed by strict rules, but it has evolved to support global languages:

  • Max Label Length: 63 characters (e.g., the specific "google" part).
  • Max FQDN Length: 253 characters total (bytes).
  • IDN & Punycode: To support non-ASCII chars (like emojis or foreign scripts), DNS uses Punycode. mรผnchen.de becomes xn--mnchen-3ya.de.
  • Case Insensitivity: Google.com is treated exactly the same as google.com.

03 Server Hierarchy

DNS is a team sport. Different servers have different jobs. It helps to think of them as a chain of command.

Recursive Resolver "The Librarian" Root Server TLD Server Authoritative Server
Mnemonic: R.R.T.A (Real Resolvers Take Action)
Recursive โ†’ Root โ†’ TLD โ†’ Authoritative.
This is the standard path a query takes through the internet.

Recursive (The Librarian)

Accepts your query and does the running around for you. It knows who to ask next. Examples: 8.8.8.8, 1.1.1.1.

Root (The Directory)

There are 13 logical root server IP addresses (A through M), managed by 12 organizations (e.g., Verisign, NASA, ICANN). However, thanks to Anycast, there are actually thousands of physical servers worldwide responding to these 13 IPs.

TLD (The Manager)

Manages a specific extension (.com, .net). Knows which authoritative server holds the actual data.

Authoritative (The Source)

The only server that actually holds the answer (the IP address). The "Source of Truth".

Deep Dive: Public vs. Private DNS (Split-Horizon)

Not all DNS is public. In enterprise environments, we often use Split-Horizon DNS.

  • Public View: If someone asks for portal.company.com from home, they get a public IP (e.g., VPN gateway).
  • Private View: If an employee asks from inside the office, they get a private local IP (e.g., 192.168.x.x) for faster, direct access.
Deep Dive: The Governance Chain (Who owns what?)

It helps to think of domains like the Real Estate market. There is a strict chain of command:

  1. ICANN (The Landlord): The global non-profit that coordinates the "Root". They decide which extensions (TLDs) exist (like creating a new city).
  2. The Registry (The Property Manager): An organization designated to manage a specific TLD.
    • Verisign manages .com.
    • PIR manages .org.
    • Educause manages .edu.
    They maintain the master database of all names ending in their extension.
  3. The Registrar (The Real Estate Agent): Retail companies like GoDaddy, Namecheap, or Cloudflare. You buy from them. They pay the Registry a fee to write your name in the master book.
  4. The Registrant (The Tenant): You. You lease the domain for a year. You don't "own" it forever; you rent rights to it.

04 Resource Records (RR)

A DNS Zone file isn't just a list; it's a structured database. Each entry is a Resource Record (RR). As an engineer, you must choose the specific tool for the job.

A
Address Record

Maps a Hostname → IPv4 Address. This is the most fundamental record type. It answers "What is the IP for this name?"

google.com. IN A 142.250.190.46
4A
AAAA Record

Maps a Hostname → IPv6 Address (128-bit). As IPv4 addresses are exhausted, AAAA records are essential for the modern internet.

google.com. IN AAAA 2001:4860:4860::8888
CN
CNAME (Canonical Name)

The Alias. Maps Hostname → Hostname. Crucial for directing www to the naked domain. Warning: It triggers a second lookup (chaining).

www.google.com. IN CNAME google.com.

โš ๏ธ RFC Rule: Cannot exist at the Root (@).

SV
HTTPS / SVCB

The Modern Standard. Allows CNAME-like behavior at the root (@) and hints protocol support (like HTTP/3) to browsers.

@ IN HTTPS 1 . alpn="h3,h2"
MX
Mail Exchange

The Postman. Directs email traffic. Uses Priority integers to define primary vs. backup servers.

@ IN MX 10 smtp.google.com.
TX
TXT Record

The Sticky Note. Arbitrary text. Primarily used for email security (SPF, DKIM, DMARC) and verifying domain ownership for tools like Google Console.

@ IN TXT "v=spf1 include:_spf.google.com ~all"
PT
PTR Record

Reverse DNS. Maps IP → Hostname. Crucial for email servers to verify sender identity and avoid spam filters. (Opposite of A record).

46.190...in-addr.arpa IN PTR google.com.
SR
SRV Record

Service Discovery. Format: _service._proto.name. Defines hostname + port + priority + weight. Used for SIP (VoIP), LDAP, and Minecraft.

_sip._tcp IN SRV 10 60 5060 sipserver
Deep Dive: The "Glue Record" Paradox

Here is a classic chicken-and-egg problem in DNS:

  1. The .com TLD says: "To find example.com, go ask the nameserver ns1.example.com."
  2. The browser asks: "Okay, but what is the IP address of ns1.example.com?"
  3. The TLD says: "That information is inside example.com... which you are trying to reach."

The Solution: Glue Records.

The TLD Registry stores a "cheat sheet" (Glue Record) that provides the IP of the nameserver directly, preventing the infinite loop. It effectively says: "Go to ns1.example.com, and by the way, its IP is 1.2.3.4."

Deep Dive: The SOA Record (Heart of the Zone)

SOA (Start of Authority) is the "Manager" record. It dictates how data propagates between Primary and Secondary servers.

google.com.  IN  SOA  ns1.google.com. admin.google.com. (
    2026010301 ; SERIAL (YYYYMMDDnn) - If this increases, slaves sync.
    7200       ; REFRESH - Check for updates every 2 hours.
    3600       ; RETRY - If primary fails, retry in 1 hour.
    1209600    ; EXPIRE - If down for 14 days, stop answering.
    86400 )    ; MINIMUM TTL - Cache "Not Found" errors for 1 day.

05 Resolution Process

Let's follow the complete lifecycle of a DNS query. When you type google.com, your ISP's Recursive Resolver acts as a "detective," gathering information step-by-step.

YOU Stub Resolver ISP RESOLVER The Manager ROOT (.) .COM GOOGLE 1 2 3 4 5 6 7 8

Step-by-Step Breakdown

  1. Step 1: You ask the ISP ("Recursive Resolver") for google.com.
  2. Step 2 & 3: ISP asks the Root (The King). Root replies: "I don't know, ask .COM."
  3. Step 4 & 5: ISP asks .COM (The Manager). TLD replies: "I don't know, ask Google's Server."
  4. Step 6 & 7: ISP asks Google (Auth). Google replies: "Here is the IP: 142.250.190.46."
  5. Step 8: ISP gives the IP to you and saves it in cache.
Deep Dive: Recursive vs. Iterative (The Crucial Difference)

This distinction defines how DNS workloads are distributed across the internet. It is the difference between "delegating a task" and "doing it yourself".

Recursive Query

"Do the work for me."

The client sends a request and expects the final answer.

Iterative Query

"Point me to the answer."

The server replies with the best answer it knows (a referral).

Expert Note: EDNS0
Modern DNS often carries extra data (like your subnet for CDN localization) using EDNS0. This extends the classic 512-byte UDP limit, allowing larger responses without switching to TCP immediately.

06 Caching & TTL

If we did that 5-step journey for every single request, the internet would crawl. We solve this with Caching (Saving the answer).

Layer 1: Browser Cache (Chrome remembers for ~60s).
Layer 2: OS Cache (Windows/Mac remembers).
Layer 3: ISP Cache (Your Internet Provider remembers for everyone in your neighborhood).
Metaphor: The Milk Carton
TTL (Time To Live) is like the expiry date on milk. When you buy milk (cache data), you check the date. If it's valid, you drink it. If it's expired, you go back to the store (server) to get fresh milk.

Short TTL (e.g., 60s)

Used for "Fast Flux" networks, Load Balancers, or during migrations. Changes propagate quickly but server load is higher.

Long TTL (e.g., 86400s)

Used for stable infrastructure (MX records, DKIM). Reduces server load but changes take time to propagate.

Deep Dive: Propagation & Cache Eviction

For Beginners: The "Rumor" Analogy

Imagine you tell 5 friends (ISPs) that you moved to a new house. They write it down in their notebooks (Cache). If you move again tomorrow, they won't know until they check their notebooks and see the note "Check again in 24 hours" (TTL).

Propagation is simply the time it takes for everyone's "Check again" timer to run out. You cannot force them to forget; you just have to wait.

For Engineers: Advanced Mechanics

  • Scenario: The "Big Migration" Strategy
    To avoid downtime during an IP change:
    1. 48h Before: Lower TTL to 300s (5 mins).
    2. Migration Day: Change DNS. The world sees the new IP in ~5 mins.
    3. Cleanup: Raise TTL back to 86400s (24h) to reduce server load.
  • Cache Eviction (LRU):
    Resolvers have finite RAM. Even if your TTL is 24 hours, if your domain is rarely visited, a busy ISP resolver might evict your record early to make space for a more popular one (e.g., youtube.com) using a Least Recently Used (LRU) algorithm.
  • Negative Caching (SOA):
    If a record doesn't exist (NXDOMAIN), resolvers cache that "non-existence" too! The duration is controlled by the MINIMUM TTL field in the SOA record, not the record's own TTL. This prevents DoS attacks from non-existent random subdomains.

07 Security & Tools

DNS was designed in the 1980s based on trust. It assumes everyone on the network is honest. In 2026, that is a dangerous assumption.

THE ATTACK: CACHE POISONING RACE 1. Query: "bank.com?" (ID: 5592) 2. Hacker Floods FAKE Answers "ID: 5590? 5591? 5592?" 3. Fake Reply WINS! Resolver accepts ID: 5592 4. Real Reply (Too Late) RESOLVER (Victim) REAL BANK โ˜ ๏ธ HACKER Key: 5592
The Race Condition: DNS uses UDP, which is fast but "naive." A resolver simply accepts the first answer it receives. If a hacker guesses the Transaction ID and sends a fake reply faster than the real server, the resolver saves (caches) the fake IP. Everyone using that ISP is now sent to the hacker's site.

Defense: The Chain of Trust

๐Ÿ”’DNSSEC

Digital Signatures. Cryptographically signs records (RRSIG) to prove the data wasn't tampered with. It creates a Chain of Trust from Root down to the domain.

๐Ÿ›ก๏ธAnycast

DDoS Protection. 1 IP = Many Servers. An attack from Asia goes to the Asian server, protecting the US server. It dilutes attacks globally.

๐Ÿ‘๏ธODoH (2026)

Oblivious DoH. Separates "Who" from "What". A Proxy sees the Client IP; the Target sees the Query. Neither sees both.

Expert Tool: The Terminal

Network engineers live in the terminal to debug DNS issues. The tools vary by operating system:

# Linux / macOS (Using DIG)
student@terminal:~$ dig google.com +short
142.250.190.46
# Windows CMD (Using NSLOOKUP)
C:\Users\Student> nslookup google.com
Deep Dive: Interpreting Error Codes & Attacks
  • NOERROR: Success!
  • NXDOMAIN: Domain doesn't exist.
  • SERVFAIL: Server Failure (often DNSSEC validation failure).
DDoS Amplification: Hackers spoof a victim's IP and send small queries (60 bytes) to open resolvers asking for large records (3000 bytes). The victim gets crushed by the responses.

08 Knowledge Check

1. What happens if the TTL is set to 0?

The site goes down forever.โญ•
The record is never cached.โœ…

2. Which record type is crucial for HTTP/3 support?

CNAMEโญ•
HTTPS / SVCBโœ…

3. How many Logical Root Server IPs exist?

13โœ…
Thousandsโญ•