Skip to main content

Command Palette

Search for a command to run...

DNS Explained-Clean Guide

Published
6 min read
A

Focused on : Product Design and Development

Code Architecture, Scaling, Data processing

Team building and co-ordinate with management

Use of AI Agent to build effective web applications

Building Live real time B2C business platforms

What is DNS?

DNS (Domain Name System) is the Internet’s directory service.

Humans prefer names.
Computers prefer numbers.

DNS acts as a translator that converts a hostname (like google.com) into an IP address (like 142.250.192.14) that computers understand.

Without DNS, we would have to remember IP addresses for every website we visit—which is not practical.


Why DNS Exists

Imagine the internet without DNS:

  • You type google.com

  • Instead, you would need to type 142.250.192.14

  • For every website

  • Every time

DNS solves this by storing key–value mappings:

  • Key → Hostname

  • Value → IP address

This is similar to a telephone directory:

  • Person’s name → Phone number

DNS is a Distributed System

DNS is not a single server.

If DNS were centralized:

  • It would be a single point of failure

  • Internet-wide latency would be very high

  • Maintenance would be impossible at global scale

So DNS is designed as a distributed, hierarchical system with servers spread all over the world.


DNS Server Hierarchy

DNS works in layers. Each layer has a specific responsibility.

1. Root DNS Servers

  • There are 13 logical root DNS servers, named A to M

  • Each root server is replicated globally for reliability and performance

  • Root servers do not store IP addresses

  • They only tell you which Top-Level Domain (TLD) server to ask next

Example:
If you search for google.com, the root server points you to the .com TLD server.


2. Top-Level Domain (TLD) Servers

TLD servers handle:

  • Generic domains: .com, .org, .net

  • Country domains: .in, .uk, .fr

Their job:

  • Tell you which authoritative DNS server owns the domain

Example:

  • .com TLD server points to Google’s authoritative DNS servers.

3. Authoritative DNS Servers

These are the final and most important servers.

  • Owned by organizations (Google, Amazon, universities, companies)

  • Store actual DNS records

  • Provide the final IP address for a domain

Only authoritative servers give the real answer.


4. Local DNS Server (Resolver)

This is the DNS server closest to the user.

  • Provided by ISP, company, university, or cloud provider

  • Acts as a proxy between the user and the DNS hierarchy

  • Performs lookups on behalf of the user

  • Caches responses to improve performance


Types of DNS Queries

There are two types of DNS queries:

1. Recursive Query

  • From user (browser/OS) to local DNS server

  • The user expects a final answer

  • Responsibility is fully on the local DNS server


2. Iterative Query

  • Between DNS servers (local → root → TLD → authoritative)

  • Each server replies with the next place to ask

  • Used internally within the DNS hierarchy

Important rule:

Only the query from the user to the local DNS server is recursive.
All other queries are iterative.


DNS Caching

DNS responses are cached to improve speed.

  • When a DNS server receives a response, it stores it in memory

  • Future requests for the same domain are answered quickly

  • Cached entries expire based on TTL


DNS Records (Resource Records)

DNS stores information in the form of Resource Records (RRs).

Each record has four fields:

  1. Name – domain or hostname

  2. Value – IP address or another hostname

  3. Type – record type

  4. TTL – time to live (cache duration)


Common DNS Record Types

A Record

Maps a hostname to an IPv4 address.


NS Record

Specifies the authoritative DNS server for a domain.


CNAME Record

Creates an alias for another hostname.


MX Record

Specifies the mail server for a domain.


AAAA Record

An AAAA record maps a hostname to an IPv6 address.

  • Name: google.com

  • Value: 2404:6800:4009:80b::200e

Why is it called AAAA?

  • An A record maps to an IPv4 address (32-bit)

  • An AAAA record maps to an IPv6 address (128-bit)

You can think of it as:

  • A → IPv4 (older internet)

  • AAAA → IPv6 (modern, scalable internet)


Why IPv6 and AAAA Records Exist

IPv4 addresses are limited and almost exhausted.
IPv6 was introduced to:

  • Provide a much larger address space

  • Support billions of devices

  • Enable long-term internet growth

DNS supports both IPv4 and IPv6, so:

  • Websites can have A records, AAAA records, or both

  • Modern systems prefer IPv6 if available


How Browsers Use AAAA Records

When a browser resolves a domain:

  1. It first checks for an AAAA record

  2. If found, it uses the IPv6 address

  3. If not found, it falls back to the A record

This allows backward compatibility while supporting newer networks.


Simple Rule to Remember
  • A record → Hostname → IPv4 address

  • AAAA record → Hostname → IPv6 address

Both serve the same purpose; only the IP version differs.


Why the Next Version Was IPv6 (Not IPv5)

When IPv4 address exhaustion became a serious problem, the IETF needed a true replacement.

They chose:

  • IPv6 instead of IPv5

  • To avoid:

    • Protocol confusion

    • Compatibility issues

    • Reusing an already-reserved version number

Thus:

  • IPv4 → production

  • IPv5 → experimental, discarded

  • IPv6 → production replacement


Why IPv4 Was Not Extended Instead

IPv4 limitations:

  • 32-bit address space (~4.3 billion addresses)

  • No built-in security

  • Poor scalability for modern Internet

IPv6 solved this cleanly instead of patching IPv4.


Will IPv8 Come?

Short Answer

Very unlikely. Not anytime soon.

Version Numbers Are Not Sequential Roadmaps

IP version numbers are not promises of future releases.

A new IP version would only be created if:

  • IPv6 fundamentally fails

  • A completely new networking model is required

Currently:

  • IPv6 is still not fully adopted worldwide

  • There is no technical pressure for IPv7 or IPv8


TTL (Time To Live)

TTL defines:

  • How long a DNS record can stay in cache

  • When it should be removed and refreshed

Short TTL:

  • Faster updates

  • More DNS queries

Long TTL:

  • Better performance

  • Slower propagation of changes


DNS and Port Numbers

  • DNS uses port 53

  • Queries and responses are usually sent using UDP

  • TCP is used for large responses or zone transfers

Most DNS servers run on UNIX/Linux systems using BIND (Berkeley Internet Name Domain).


How DNS Works When You Open a Website

When you open google.com:

  1. Browser checks local cache

  2. If not found, asks local DNS server

  3. Local DNS queries root server

  4. Root server points to .com TLD

  5. TLD server points to Google’s authoritative server

  6. Authoritative server returns IP address

  7. Local DNS caches the response

  8. Browser initiates TCP/HTTPS connection using IP

DNS resolution happens before TCP connection.


Hostname vs Alias

  • google.com is the canonical name

  • www.google.com can be an alias

  • CNAME records are used to map aliases to canonical names


DNS Design Summary

  • DNS is distributed, not centralized

  • Uses a hierarchical structure

  • Designed for scalability, fault tolerance, and performance

  • Acts as a black box translation service

  • Converts network names to network addresses


Final Takeaway for Students

Think of DNS as:

  • A global, distributed phone directory

  • That works silently in the background

  • Every time you open a website

  • Without you even noticing

Understanding DNS deeply helps you:

  • Debug production issues

  • Design scalable systems

  • Perform better in interviews

  • Think like a network engineer

More from this blog

coffee-with-aniruddha

12 posts

Anirudha, A Tech professional, Experienced in Web Development, Writing these blogs to share the knowledge.