DNS = Domain Name System
It's like the phonebook of the internet.
Imagine you want to call your friend Rahul, but you don’t remember his phone number. Instead, you just look for "Rahul" in your phone contacts, and your phone automatically dials the correct number for you.
Similarly, when you type a website like:
www.google.com
Your computer doesn’t understand names — it needs an IP address like:
142.250.64.78
So DNS acts like your phone contacts: it converts website names into IP addresses.
Let’s say you open your browser and type:
www.netflix.com
Your computer asks:
“What is the IP address of www.netflix.com?”
This is like an assistant who goes to find the answer. Usually handled by your ISP (like Jio, Airtel) or Google DNS (8.8.8.8).
First, it checks if it already knows the answer.
If it does, it returns quickly. ✅
It goes and asks 3 main servers:
- Root Server – “Where can I find .com websites?”
- TLD Server (Top Level Domain) – “Where’s netflix.com?”
- Authoritative Server – “Here’s the IP address of www.netflix.com!”
The resolver gives that IP address to your computer.
Now your browser connects to that IP and shows you the Netflix homepage.
- It makes browsing fast and easy.
- Without it, you’d have to remember IPs like
192.168.1.1
. - It helps websites load faster through caching.
- DNS also helps protect against malicious websites using security features.
Real World | DNS Equivalent |
---|---|
Contact name | www.netflix.com |
Phone number | 142.250.64.78 (IP address) |
Your phone | Web browser |
Contact search | DNS resolver |
Great bro! 🔥 Let’s go deeper into DNS — covering the main parts step-by-step in simple language, with examples. We'll talk about: |
- 🔁 How DNS works (deeper)
- 🧾 Types of DNS records
- 🗂️ DNS caching
- 🔐 DNS security
Imagine you type:
www.facebook.com
Here’s what happens under the hood:
Your browser checks:
“Have I already visited this recently?”
If yes, it remembers the IP and uses it instantly.
If browser doesn’t know, your computer’s OS checks:
“Do I have it stored in memory?”
If your OS doesn’t know, it contacts a DNS Resolver, like:
- Google DNS (
8.8.8.8
) - Cloudflare DNS (
1.1.1.1
) - ISP DNS
It says:
“Hey, do you know where www.facebook.com is?”
If resolver doesn’t know, it asks:
“Who handles
.com
domains?”
Root Server replies:
“Ask the
.com
server.”
Now it asks the .com
server:
“Where can I find facebook.com?”
TLD server replies:
“Ask the authoritative server for facebook.com.”
This is the final boss.
It knows:
“Yes! www.facebook.com = 157.240.20.35”
That IP is returned to your browser.
Now, your browser goes to:
http://157.240.20.35
And loads Facebook!
Each domain has DNS Records, like entries in a notebook.
Record Type | What It Does | Example |
---|---|---|
A | Maps domain to IPv4 address | facebook.com → 157.240.20.35 |
AAAA | Maps domain to IPv6 address | example.com → 2606:4700::1111 |
CNAME | Alias to another domain | www.example.com → example.com |
MX | Mail server info | Used for sending/receiving emails |
NS | Name servers of domain | Who handles DNS for the domain |
TXT | Text info (used for security, verification) | SPF, DKIM, etc. |
To avoid doing this long process every time, DNS uses caching.
- Browser Cache: Remembers recently visited sites.
- OS Cache: System memory stores IPs for quick reuse.
- Resolver Cache: Your ISP or Google keeps a memory of IPs it already fetched.
If you visit www.google.com
:
- First time = full DNS lookup 🕐
- Second time = fast, from cache ⚡
Each DNS record has a TTL (Time to Live) — defines how long it can be cached.
Standard DNS is old and not encrypted. Hackers can spy or redirect you.
- DNS Spoofing: Attacker tricks DNS and sends you to a fake website.
- Man-in-the-Middle Attacks
Protocol | Description |
---|---|
DNSSEC | Adds a digital signature to DNS records (verifies data isn’t changed) |
DoH | DNS over HTTPS (encrypts your DNS traffic) |
DoT | DNS over TLS (also encrypts DNS traffic) |
Let’s say:
- You want to visit "PIZZA HUT".
- You don’t know the address, so you ask someone (DNS Resolver).
- That person asks others (Root, TLD, Authoritative) and finds it.
- You note it down (Caching).
- Next time, you go directly to the address.