Every house in a city has a unique address so that letters and parcels can reach the correct destination. The internet works the same way.

Every website lives on a computer (server), and every server has a unique numeric address, called an IP address β€” for example:104.26.10.229

But let's be honest β€” humans are terrible at remembering numbers.

That's why we use DNS (Domain Name System).

What is DNS?

DNS is the internet's phonebook.

It translates human-readable domain names into machine-readable IP addresses, so browsers know where to go.

Simple example:

xyz.com β†’ DNS β†’ 104.26.10.229 β†’ Website loads

You type a name. DNS finds the number. Your browser connects to the server.

Simple β€” but powerful.

None

What Happens When You Type a Website?

Let's say you open your browser and type:www.xyz.com

Behind the scenes, this is what actually happens

DNS Resolution β€” Step by Step

Local Cache Check

Your computer first checks:

"Do I already know the IP address for this domain?"

If yes β†’ instant response (very fast). If not β†’ it asks for help.

Recursive DNS Server (Your Helper)

Your system sends the request to a Recursive DNS Resolver (usually provided by your ISP, Google DNS, or Cloudflare DNS).

The resolver:

  • Checks its own cache
  • If found β†’ returns the IP
  • If not β†’ starts searching for it

Root DNS Servers

The resolver asks a Root DNS Server:

"Where can I find information about .com domains?"

The root server replies:

"I don't know the IP, but I know who manages .com. Go there."

TLD DNS Servers

Now the resolver contacts the TLD (Top-Level Domain) server for .com.

The TLD server responds:

"The authoritative nameservers for tryhackme.com are hosted on Cloudflare."

Authoritative DNS Server

This is the final authority.

The authoritative server:

  • Stores the actual DNS records
  • Returns the real IP address:104.26.10.229

Response + Caching (TTL)

The resolver:

  • Sends the IP back to your computer
  • Saves it in cache for a specific time (TTL β€” Time To Live)

Your browser now connects to the server, and the website loads

Real-Life Analogy

Think of it like finding a friend's house:

  1. You check your own diary (local cache)
  2. Ask a friend (recursive resolver)
  3. Friend checks city index (root server)
  4. Finds the area office (TLD server)
  5. Goes to the house owner (authoritative server)
  6. Gets the exact address and remembers it for next time (cache)

Understanding Domains: TLD, SLD & Subdomains

πŸ”Ή TLD (Top-Level Domain)

The right-most part of a domain.

Examples:

  • .com
  • .org
  • .in
  • .uk

Types:

  • gTLD (Generic): .com, .org, .net
  • ccTLD (Country Code): .in, .ca, .uk

πŸ”Ή Second-Level Domain (SLD)

The part just left of the TLD.

Example:xyz.com

  • TLD β†’ .com
  • SLD β†’ tryhackme

Rules:

  • Max 63 characters
  • Allowed: a–z, 0–9, -
  • Hyphens cannot start or end the name

πŸ”Ή Subdomain

Anything left of the SLD.

Example:admin.xyz.com

  • Subdomain β†’ admin

You can create multiple levels:jupiter.servers.xyz.com

Each label:

  • Max 63 characters
  • Max 253 characters

Common DNS Record Types (Must-Know)

DNS is not just about IPs. It stores different record types for different purposes.

None
None

Why MX & TXT Records Matter

  • MX records decide where emails are delivered
  • TXT records help prevent email spoofing and spam
  • Used for domain ownership verification (Google, AWS, etc.)