DNS: The Web’s Secret Engine 🌐

DNS: The Web’s Secret Engine 🌐

Introduction

Have you ever wondered how typing “example.com” intp your browser’s address bar instantly takes you to the right website? 🌍 It’s all thanks to something called DNS – the Domain Name System.
In this blog, we’ll break down DNS in a simple way, show you the types of DNS records, explain how the DNS hierarchy works, and give you a clear understanding of this hidden hero of the internet.
Let’s get started!


DNS - Domain Name System

Imagine trying to remember the phone number of every person you want to contact. That would be a nightmare, right? 📱 Instead, you use names (like “Mom” or “Best Friend”) to make calling easier. DNS is similar — it matches easy-to-remember domain names like “example.com“ with the actual numeric addresses (IP addresses) that computers use to find each other.

  • DNS is a hierarchical, decentralized naming system used to find the correct place (ip address) of any hosted website over the internet. It store ip address for all the domain names.

  • DNS acts as the “phonebook” of the internet, allowing users to access websites using simple domain names instead of remembering numeric IP addresses, enabling smooth and efficient navigation of the web.

Importance of DNS

  1. Simplifies Internet Navigation: It enables us to access websites using domain names instead of complex numeric IP addresses, making the internet more user-friendly.

  2. Scalability: It allows the internet to scale by supporting millions of domain names and corresponding IP addresses, enabling the seamless operation of websites, services, and applications across the globe.

  3. Security: It helps in filtering malicious websites (through DNS-based filtering), preventing phishing attacks, and supporting additional security protocols to prevent data tampering.


Types of DNS Records

  1. A (Address) Record:

    • Maps a domain name to its corresponding IPv4 address.

    • Example: example.com192.0.2.1

  2. AAAA (IPv6 Address) Record:

    • Maps a domain name to its corresponding IPv6 address.

    • Example: example.com2001:0db8:85a3:0000:0000:8a2e:0370:7334

  3. CNAME (Canonical Name) Record:

    • Creates an alias for an existing domain. It points a domain to another domain name, allowing multiple domain names to point to the same IP address.

    • Example: www.example.comexample.com

  4. NS (Name Server) Record:

  5. PTR (Pointer) Record:

    • Used for reverse DNS lookups, where an IP address is mapped back to a domain name.

    • Example: 192.0.2.1example.com


DNS hierarchy

The hierarchy starts at the root and goes all the way down to the authoritative DNS servers.

1. Root Level (Root DNS Servers)

  • The DNS hierarchy starts at the very top with the root.

  • There are 13 root servers worldwide (labeled A through M), which are responsible for knowing where the servers for Top-Level Domains (TLDs) are located.

  • When a DNS query is first made (for example, www.example.com), if the resolver doesn't already know the IP address, it queries the root servers.

  • The root server doesn’t have the exact IP for the domain but will direct the query to the appropriate TLD name servers (like .com, .org, .net).

2. Top-Level Domain (TLD) Servers

  • The next level in the hierarchy is the TLD name servers.

  • These servers are responsible for managing the domain extensions (like .com, .org, .net, .edu, etc.).

  • For example, if you’re querying “jaygovind-blogs.com“, the root DNS servers will direct your query to the .com TLD server.

  • The TLD servers don't have the exact IP for the website either, but they know which authoritative DNS servers are responsible for the second-level domain

3. Authoritative DNS Servers (Second-Level Domain)

  • Authoritative DNS servers hold the actual DNS records (like A, MX, CNAME) for a specific domain, such as jaygovind-blogs.com.

  • When the TLD server directs the query to the authoritative server for jaygovind-blogs.com“, it is this server that contains the final and authoritative response for the IP address or other DNS records for the domain.

  • For example, it will have the mapping for jaygovind-blogs.com192.0.2.1 (or whichever IP address is assigned).

What happens if a DNS root server becomes unavailable?
If a DNS root server becomes unavailable, the anycast system ensures that the traffic is automatically rerouted to the next available copy of the server. Since there are many copies of each root server around the world, the system is resilient and can still function even if some servers go down. DNS continues to work smoothly, though a temporary slowdown might happen if multiple servers experience issues. Additionally, if a root server does go down, it usually gets restored quickly due to its global importance.

DNS Resolution/ Lookup

It is the process that helps devices and applications to translate readable domain names to the corresponding IP Addresses used by the computers for communicating over the web.

What Are The Steps in a DNS Lookup?

  1. A user types “jaygovind-blogs.com” into a web browser.

  2. The request goes to a DNS resolver.

  3. The resolver asks a root server where to find the top-level domain (TLD) server for .com.

  4. The root server tells the resolver to contact the .com TLD server.

  5. The resolver then asks the .com TLD server for the IP address of “jaygovind-blogs.com

  6. The .com TLD server gives the resolver the IP address of the domain’s nameserver.

  7. The resolver then asks the domain’s nameserver for the IP address of “jaygovind-blogs.com

  8. The domain’s nameserver returns the IP address to the resolver.

Example:

  • Imagine you want to visit New York City (access a website), but you don’t know the exact flight details (IP address). First, you go to your local travel agent (DNS resolver), who checks if they already know the flight details. If not, they start searching. The agent first directs you to the airport’s main desk (root DNS servers), which doesn't know the exact flight but can point you to the right airline (e.g., international airlines for .com domains). The desk then sends you to the airline counter (TLD servers) responsible for your specific destination (like example.com). Finally, the airline's own counter (authoritative DNS servers) provides the exact flight details (IP address). With the flight details, you board the plane (connect to the website) and arrive at your destination (the website). Each step involves delegating the search from one authority to the next, ultimately leading you to the correct destination.

💡
Have you ever wondered how the internet can handle millions of queries every second without getting overwhelmed? 🤯 How does DNS manage to stay so fast and reliable across the globe? Drop your thoughts in the comments below!