What Really Happens When You Visit a Website?
You type google.com.
Less than a second later you're watching YouTube, reading emails, or searching the web.
It feels instant.
But before your browser can even request a webpage, an entire conversation happens across the Internet.
Your computer has one important question:
"Where is google.com?"
That question is answered by one of the oldest and most important systems on the Internet:
DNS — the Domain Name System.
Think of DNS as the Internet's phonebook.
Instead of remembering IP addresses like
142.250.190.46
we remember names like;
google.com
DNS translates those human-friendly names into machine-friendly IP addresses.
Let's see exactly how that happens.
Why Do We Need DNS?
Imagine if every person in your contacts list had no names.
Instead of calling Mom, you'd have to memorize:
+254712345678
Now imagine doing that for every person you've ever met.
Almost impossible.
Computers have the same problem.
They communicate using IP addresses.
Humans communicate using names.
DNS bridges that gap.
The Journey Begins
Suppose you enter:
Your browser doesn't know where GitHub lives.
It starts asking around.
The entire lookup looks something like this:
You
│
▼
Browser Cache
│
▼
Operating System Cache
│
▼
Recursive DNS Resolver
│
▼
Root Name Server
│
▼
TLD Name Server (.com)
│
▼
Authoritative Name Server
│
▼
GitHub IP Address
Let's visit each stop.
Step 1 — Browser Cache
Your browser first checks:
Have I visited GitHub recently?
If yes...
github.com
↓
140.82.121.3
Done.
No Internet lookup needed.
Every browser keeps a temporary DNS cache.
Step 2 — Operating System Cache
If the browser doesn't know...
it asks the operating system.
Windows, Linux, and macOS all maintain DNS caches.
Example:
github.com
↓
140.82.121.3
Still no network request.
Step 3 — Recursive Resolver
If nobody knows...
your computer asks a DNS resolver.
Usually this belongs to:
Your ISP
Google DNS (8.8.8.8)
Cloudflare (1.1.1.1)
Quad9
The resolver's job is simple:
"Don't worry.
I'll find the answer."
This resolver does all the heavy lifting.
Step 4 — Root Name Server
The resolver first asks a Root Server:
Where is github.com?
The root server replies:
"I don't know GitHub...
but I know who manages .com."
Notice something important.
The root server doesn't know every website.
It only knows where to find top-level domains.
Step 5 — TLD Name Server
Next stop:
.com
The resolver asks:
Where is github.com?
The .com server replies:
"Ask GitHub's authoritative server."
Again...
No IP address yet.
Just directions.
Step 6 — Authoritative Name Server
Finally the resolver reaches GitHub's own DNS server.
Now it asks:
What is github.com?
The server replies:
140.82.121.3
Finally!
Now the resolver returns the answer to your computer.
Step 7 — The Browser Makes the Real Request
Only now can your browser send:
GET /
Host: github.com
to
140.82.121.3
DNS lookup is finished.
Only then does HTTPS begin.
Visualizing the Entire Journey
You
↓
Browser Cache
↓
OS Cache
↓
Recursive Resolver
↓
Root Server
↓
.com Server
↓
GitHub Authoritative Server
↓
IP Address
↓
Browser connects
Notice that DNS itself doesn't deliver webpages—it only answers the question:
"Which IP address should I connect to?"
Recursive vs. Authoritative DNS
These two are often confused.
Recursive Resolver
Think of it as your personal assistant.
You ask one question.
It does all the research.
You
↓
Resolver
↓
Internet
Examples:
Google DNS
Cloudflare DNS
ISP DNS
Authoritative Server
This server owns the official answer.
Example:
github.com
↓
140.82.121.3
Nobody argues with the authoritative server.
It's the source of truth.
Why DNS Is So Fast
The first lookup may take a few milliseconds.
The second lookup?
Almost instant.
Why?
Caching.
Once the resolver learns:
github.com
↓
140.82.121.3
it stores the answer.
The next thousand users can reuse it.
This dramatically reduces Internet traffic.
What Is TTL?
Every DNS record has a value called:
TTL
Time To Live
Example:
TTL = 3600
means
Keep this answer for one hour.
After that...
the resolver asks again.
TTL prevents outdated IP addresses from living forever.
Common DNS Record Types
DNS stores more than IP addresses.
Here are the most common record types you'll encounter:
Record Purpose
A Maps a domain to an IPv4 address
AAAA Maps a domain to an IPv6 address
CNAME Points one domain to another domain
MX Specifies mail servers for email delivery
TXT Stores text data, often used for verification and security (SPF, DKIM, DMARC)
NS Identifies the authoritative name servers for a domain
Example:
blog.example.com
↓
CNAME
↓
hosting.example.net
Try It Yourself
On Linux or macOS:
dig github.com
or
nslookup github.com
Example output:
github.com
140.82.121.3
You can even ask specific DNS servers:
dig @8.8.8.8 github.com
or
dig @1.1.1.1 github.com
This is a great way to compare responses from different resolvers.
Common Interview Questions
a.Why don't browsers connect directly using the domain name?
Because network communication happens using IP addresses. DNS translates human-readable domain names into those addresses.
b.What happens if DNS fails?
Your browser doesn't know where the server is.
You'll typically see errors like:
DNS_PROBE_FINISHED_NXDOMAIN
or
Server not found
c.Why are there multiple DNS servers?
The DNS hierarchy distributes responsibility. Root servers know top-level domains, TLD servers know authoritative servers, and authoritative servers know the actual records. This makes DNS scalable, resilient, and decentralized.
d.Does DNS happen every time I visit a website?
Not necessarily. Browsers, operating systems, and recursive resolvers cache DNS responses until the TTL expires.
Key Takeaways
Whenever you type a domain name into your browser, a carefully orchestrated lookup begins. Your browser checks its cache, then your operating system, then a recursive resolver. If needed, that resolver consults the root servers, the appropriate top-level domain server, and finally the authoritative name server to obtain the correct IP address. The result is cached for future requests, allowing subsequent lookups to happen much faster.
Without DNS, we'd have to remember numerical IP addresses for every website we visit. Instead, DNS provides a distributed, scalable naming system that makes the modern Internet usable.
The next time you type github.com or google.com and the page loads almost instantly, remember that an entire network of DNS servers worked together in just a few milliseconds to answer one simple question:
"Where can I find this website?"
Top comments (0)