DNS Hierarchy Explained : root to Authoritative Servers
How DNS Works: A Journey from Root to Authoritative Servers
Hey Everyone, let's Understand DNS in simple and animated way
Suppose you want to call your friend. You pick up your mobile phone, open the contacts app, search for your friend's name, and then make the call. After a few seconds of ringing, your friend picks up the call, and you both begin your conversation.
But in reality, you don't call your friend's name; instead, you search for your friend's name in the contacts app. The app then calls the number associated with your friend's name.
Similarly, when you type the name of a website like google.com or something similar to visit that website, you're not directly accessing the website itself. Instead, your browser uses the domain name to find the corresponding server's IP address and then connects you to the website.
So, in the case of a phone call, you know that your contacts app is converting your friend's name into their mobile number. But in the case of a website, who is responsible for converting the website name into an IP address? Do you know❔
Before moving forward, you need to understand what a domain name is. A domain name is a unique identifier associated with a website's IP address. And I believe you already know about IP addresses; if not, I will cover it in another article.
So when you want to call your friend, you don't dial your friend's mobile number each time. Instead, you simply search for their name in the app and call them. Likewise, you just enter a domain name, and a magic happens, the domain name is converted into an IP address, connecting you to the server of that website. Now, I know you're curious to learn about the magic and the magician who converts the domain name into an IP address.
So, you know that in IT, there is no magic or magician—there are practical solutions. Let's discuss some of them.
Solution 1: We can create a local file on our system that contains domain names and their corresponding IP addresses.
But you know, this isn't the right solution because:
It takes up a lot of memory on each system.
For each new website, you would need to update that directory.
IP addresses are often dynamic, so maintaining them becomes a major issue.
Solution 2: Instead of creating a directory of domain names and their corresponding IP addresses on each system, we can create a system or server that maintains the directory of domain names. Each time we want to visit a website, we can simply ask this system or server to provide the IP address of that domain name.
So, I'm sure you're now want to know about this system. This system is known as DNS (Domain Name System).
The Domain Name System (DNS) is a worldwide system that helps translate website names, like chaicode.com, into the numerical IP addresses that computers use to find each other on the internet.
DNS is a system that consists of a series of servers that help convert domain names into their corresponding IP addresses.
Now, I'm sure you have another question in your mind: why is there a series of servers in DNS? Why can't we just rely on a single DNS server?
So, there's a simple answer:
A single server can't manage millions of incoming requests each second from across the globe.
A single server can't handle the massive amount of information about domain names and their IP addresses. There are millions of websites around the world.
Additionally, even if we were capable of doing it, we can't rely on just one server because in case of any unforeseen event, like an earthquake or nuclear blast, we could lose it.
So now you definitely understand why we need a series of servers in DNS.
and thinking about it, ‘How do we connect with DNS, and how does it convert a domain name into an IP address?’
Before we explore, `how DNS works`, let's first understand about a domain name. A simple domain name looks like this: courses.chaicode.com.
You might wonder why there's a period (.) at the end of the domain name. Don't worry! The period is actually added by default by the browser, so you don't need to type it. This is why we never see it.
If you don't believe me, try this yourself: Type a domain name, for example, courses.chaicode.com
, and press Enter. Then, type courses.chaicode.com.
(with the period at the end) and press Enter. You'll find that both give the same result.
Let's understand the remaining parts of the domain name.
I know you might have some confusion now, like what a root name, top-level domain, authoritative name, or subdomain name is. Don't worry—by the end of this article, everything will be clear.
Let's see how the Domain Name System (DNS) works. We'll understand it with an example:
Suppose you search for courses.chaicode.com.
in your browser. The browser first checks its cache memory.
Cache memory is a temporary storage area that holds data for a short period. Each browser, operating system, system, and server has its own cache memory, where recently accessed or frequently used data is stored temporarily.
If the browser doesn't find the IP address corresponding to the domain name in its cache memory, it asks the operating system for the IP address.
If the operating system also doesn't have it, the request is sent to the Default DNS server, which is provided by your Internet Service Provider (ISP). The IP address of the Default DNS server is always static, allowing us to connect to it anytime.
When the Default DNS server can't find a domain name in its cache memory, it starts working step by step. First, it reads the domain name and notices a dot (.
) at the end, so it goes to a Root Name Server.
A root server is the top-level server in the DNS hierarchy. There are 13 root servers distributed worldwide, and the Default DNS connects to the nearest one.
The root server checks its memory for the domain name. If the root server doesn't find it in its cache memory, it reads the domain and focuses on the .com
part. Then, the root server provides the IP address of the .com
TLD (Top-Level Domain) server to the Default DNS.
Next, the Default DNS contacts the .com
TLD server. The .com
TLD server checks its cache memory for the domain name. If it can't find the IP address, the .com
TLD server identifies the Authoritative Name Server for the domain and sends its IP address to the Default DNS.
Finally, the Default DNS server connects to the Authoritative Name Server, which provides the exact IP address of the subdomain. The Default DNS saves this information in its cache memory for future use and sends the IP address to the operating system. The operating system then passes it to the browser, enabling the browser to connect to the website!
What are DNS record types
DNS record types are different kinds of records that give important details about a website's name or domain, like its current IP address. These records are kept in text files called zone files on the main DNS server. The information in a DNS record is written in a way that the DNS server can understand.
let's look more about major DNS record type
A record
it's a most important DNS record type.
here A stands for address
this record used to point current ip address of an domain name
it only support IPv4 address
AAAA record
it's similar to A record
only difference, it's used to point IPv6 address
an IPv6 address looks like this
3001:0db7:3c5d:0024:0000:0000:1a2f:3c1b
CNAME record
CNAME stands for canonical name
it's used to point a domain name to another
it don't point IP address, it's also used to point subdomain
NS record
NS stands for Name Server , that specify the authoritative DNS server for a domain
example :- ike ns1.examplehostingprovider.com and ns2.examplehostingprovider.com.
MX record
MX stands for mail exchange (MX) record
it's point where emails for a domain should be routed to.
an MX record makes it possible to direct emails to a mail server.