Networking - Domain Name System
1. What is DNS?
DNS (Domain Name System) is like the phonebook of the internet.
It translates human-friendly domain names (like www.google.com) into IP addresses (like 142.250.190.78) that computers use to identify each other on a network.
-
Humans → Remember domain names.
-
Computers → Communicate using IP addresses.
-
DNS bridges the gap between them.
Example:
When you type www.amazon.com in your browser:
-
DNS translates it into an IP address → 176.32.103.205.
-
Your browser uses that IP to fetch the website.
2. Why DNS is Important
Without DNS, you would need to remember numerical IP addresses for every website.
For example:
-
Instead of typing
https://172.217.5.110
, you simply type www.google.com.
3. How DNS Works (Step-by-Step Process)
Let’s understand the flow when you open a website like www.example.com:
Step 1 – DNS Query Initiation
You type www.example.com in your browser.
Step 2 – Check Local Cache
Your computer first checks:
-
Browser cache
-
Operating system cache
-
If the IP is found, it connects directly.
Step 3 – Query Recursive DNS Resolver
If not found locally, the request goes to your ISP's DNS resolver.
Step 4 – Contact Root DNS Server
If the resolver doesn’t know the IP, it asks the Root DNS Server where to find it.
Step 5 – TLD DNS Server
The root server directs the resolver to a TLD (Top-Level Domain) DNS Server based on the domain extension (.com, .org, .net, etc.).
Step 6 – Authoritative DNS Server
The TLD server sends the resolver to the Authoritative DNS Server, which holds the actual IP address for www.example.com.
Step 7 – Return the IP Address
The authoritative server replies with the IP → 93.184.216.34.
Step 8 – Connect to the Website
The resolver sends the IP back to your browser, which connects to the web server and loads the website.
4. DNS Hierarchy & Architecture
DNS follows a tree-structured hierarchy:
[Root DNS Servers]
↓
[.com] [.org] [.net] [.in] [etc.]
↓
[Authoritative Name Servers]
↓
[Domain Names → IP Mapping]
-
Root Servers → At the top, direct queries to TLD servers.
-
TLD Servers → Manage domain extensions (.com, .org, .net, etc.).
-
Authoritative Servers → Store actual IP addresses.
5. Components of DNS
-
Domain Names → Human-readable website names (e.g., google.com).
-
IP Addresses → Machine-readable identifiers (e.g., 142.250.190.78).
-
DNS Zones → Sections of DNS namespace managed by an organization.
-
DNS Records → Stored in authoritative servers, include:
-
A Record → Maps domain → IPv4 address.
-
AAAA Record → Maps domain → IPv6 address.
-
CNAME Record → Redirects one domain to another.
-
MX Record → Handles mail server info.
-
TXT Record → Stores security and verification data.
-
-
Resolvers → Perform lookups to find IP addresses.
-
Authoritative Servers → Contain final IP mappings.
6. Types of DNS Servers
a) Recursive DNS Resolver
-
Provided by your ISP or Google DNS (8.8.8.8).
-
Finds the IP address on behalf of your browser.
b) Root DNS Servers
-
Top of the DNS hierarchy.
-
13 main clusters worldwide.
-
Example:
A.ROOT-SERVERS.NET
.
c) TLD DNS Servers
-
Handle top-level domains like
.com
,.org
,.net
. -
Example: For amazon.com,
.com
TLD server provides info.
d) Authoritative DNS Servers
-
Final source of truth.
-
Contains the actual A record for a domain.
7. Types of DNS Queries
-
Recursive Query → The resolver fetches the full answer from start to finish.
-
Iterative Query → The resolver provides the next best server instead of the final answer.
-
Non-Recursive Query → The resolver already knows the answer from its cache.
8. DNS Example in Action
Scenario: You open www.flipkart.com
-
Browser asks local DNS cache → Not found.
-
Sends request to ISP DNS Resolver.
-
Resolver contacts Root Server → Directs to
.com
TLD server. -
TLD server directs to Flipkart's Authoritative DNS Server.
-
Authoritative server returns IP → 163.53.78.54.
-
Browser connects to Flipkart's server → Website loads.
9. DNS Example Records for google.com
Record Type | Host | Value | Purpose |
---|---|---|---|
A | google.com | 142.250.190.78 | IPv4 address mapping |
AAAA | google.com | 2607:f8b0:4005:80a::200e | IPv6 address mapping |
MX | google.com | smtp.google.com | Mail server |
CNAME | www.google.com | google.com | Redirect alias |
TXT | google.com | v=spf1 include:_spf.google.com | Email verification |
10. Advantages of DNS
-
User-friendly → No need to memorize IPs.
-
Scalable → Supports billions of domain names.
-
Faster browsing → Uses caching for speed.
-
Reliable → Distributed architecture prevents failures.
-
Supports load balancing → Directs users to nearest servers.
11. Disadvantages of DNS
-
Security risks → Vulnerable to DNS spoofing & DDoS attacks.
-
Centralization issues → Root servers are limited.
-
Caching delays → DNS changes take time to propagate.
-
Dependency → If DNS fails, websites become unreachable.
12. Popular Public DNS Providers
Provider | Primary DNS | Secondary DNS |
---|---|---|
Google DNS | 8.8.8.8 | 8.8.4.4 |
Cloudflare DNS | 1.1.1.1 | 1.0.0.1 |
OpenDNS | 208.67.222.222 | 208.67.220.220 |
Quad9 | 9.9.9.9 | 149.112.112.112 |
13. Real-Life Example: Netflix DNS
When you open netflix.com:
-
DNS resolves netflix.com → 52.26.14.22.
-
Netflix uses CDN (Content Delivery Network).
-
DNS automatically routes you to the nearest Netflix server for faster streaming.
14. Summary
-
DNS = Internet’s address book → Converts domain names into IP addresses.
-
Uses a hierarchical structure → Root → TLD → Authoritative.
-
Involves DNS records like A, MX, CNAME, TXT.
-
Used in browsing, emails, video streaming, and cloud services.