DNS | Domian Name System

DNS | Domian Name System

What is DNS?

DNS stands for Domain Name System. Understand DNS as a universal telephone number book in which you can search for any IP address.

Earlier machines used to connect with the help of IP addresses, which somewhat looked alike 197.234.234.34 , but since we humans are more accustomed to names like google.com , facebook.com we created the DNS.

Before diving deep into how a DNS works, first we need to understand different types of DNS queries ( for better understanding in further theories ).

Query Types

In DNS there are three types of queries:

  1. Recursive

  2. Iterative

  3. Non - recursive

Let's discuss each one of them in detail.

Recursive

In a recursive DNS query, when a user requests the DNS record it will either respond to the user with the requested resource or will with an error message if it can't resolve that.

Iterative

In an interactive query, when a user requests a response, the DNS resolver first checks its cache memory, if it finds the requested data, it responds to the user with the requested data otherwise if it has no data it goes to the root server to request the data.

Non - recursive

A non-recursive query is a query in which the DNS Resolver already knows the answer. It either immediately returns a DNS record because it already stores it in the local cache, or queries a DNS Name Server which is authoritative for the record, meaning it holds the correct IP for that hostname. In both cases, there is no need for additional rounds of queries (like in recursive or iterative queries). Rather, a response is immediately returned to the client.

How does a DNS work?

Above is a diagram that demonstrates how a DNS server works.

Let's try to understand step-by-step

  1. A client types google.com into a web browser, the request travels through the internet and goes to a DNS resolver.

  2. If the IP is found in the cache memory of the DNS resolver, it returns the IP to the client, but since it does not know it goes to the root server.

  3. The root server searches for the IP address in its memory, and when it is not found, it returns the IP address of the TLD (Top Level Domain (will discuss this further)).

  4. Then the resolver requests the .com TLD.

  5. The TLD when does not find the requested IP in its memory, returns the IP of the Authoritative DNS server ( a server where all the IP addresses are stored )

  6. The resolver requests the authoritative DNS server and finally gets the IP address of google.com

  7. The IP address is returned to the resolver.

  8. The resolver responds to the web browser with the requested IP address.

Server Types

DNS resolver

A DNS resolver is like a middleware that sits in between the client and other DNS servers. When requesting an IP, it first tries to find the IP in its cache memory, if not found it goes to the root server.

Root server

A root server accepts the request from the DNS resolver, and responds with a TLD nameserver, based on the extension of that domain (.com, .org, .in ). Each domain name extension has a different TLD server.

TLD nameserver

A TLD server stands for Top Level Domain, it contains all the IP addresses of the same domain extensions such as .com, .net , or whatever comes to last in the domain URL.

There are two main groups of TLD:

  1. Generic top-level domains: These domains like .org, .com, .net, etc

  2. Country code top-level domains: These domains like .in, .us, .uk , etc

Authoritative DNS server

This is the last step in finding an IP address, consider this as a phone book that stores all the IP data.

Sub Domains

A subdomain is an additional part of our main domain name. It is commonly used to logically separate a website into sections. We can create multiple subdomains or child domains on the main domain.

For example, blog.example.com where blog is the subdomain, example is the primary domain and .com is the top-level domain (TLD). Similar examples can be support.example.com or careers.example.com.

Conclusion

So, till now I guess you must have understood what a DNS is, and how a DNS works.

If you found the article helpful, drop a like and support me on my socials.

Did you find this article valuable?

Support Manas Upadhyay by becoming a sponsor. Any amount is appreciated!