Get to Know DNS: The Basics & How it Works

Domain name system shortly named DNS is the backbone of the internet. We cannot even imagine the internet without DNS. DNS is called the phonebook of the internet which maps a domain name to its IP address.

Why do we need DNS?

Before understanding what is DNS we need to know why we need DNS and its importance.
All systems connected to the internet will have a unique IP address which other machines used to communicate with. Let us imagine website A connected to a server with a unique IP address 172.168.1.1 so without DNS we need to memorize this IP address and hit this IP address in our browser in order to load the website.

In a similar case to our normal phonebook, we can’t remember each and every person’s phone number but we know the names so we are saving the phone number to the name associated with it. For example, I know tom which is a school friend of mine he has given me his phone number once but it’s hard to memorize his phone number every time and do it accordingly so what we do is save tom’s phone number in our phonebook so whenever I need to call him I just need to dial the contact tom it automatically matches to his phone number, super easy.

This is the exact concept behind the working of DNS. What DNS does is to map a domain name (example.com) to an IP address (the IP address of the server it is hosted). So whenever we need to access example.com we can simply type the domain name rather than the IP address of the server it is hosted.DNS does the rest of the look-up process and loads the website files from the server where it is hosted.

How does the DNS lookup process work?

Now we got a basic understanding of DNS but there are millions and billions of website and application over the internet how does DNS correctly maps the exact server’s ip address with the domain name?

In order to understand the DNS lookup process. You need to understand the 4 servers involved in the DNS lookup process. Similar to the diagram a request from clients routes through all these servers in order to complete the DNS lookup process.

1: Recursive resolver.

The DNS recursor is a server designed to receive queries from client machines through applications such as web browsers. That means recursor doesn’t exactly know the IP address but its duty is to find all the matching places and comes back with an address if found and return an error if not found.
Typically the recursor is then responsible for making additional requests in order to satisfy the client’s DNS query.

When the Recursive resolver receives a request from the client it initially checks its cached data and if not found then forward the request to the next server the root nameserver. It also sends back the address received from the authoritative nameserver to the client.

2: Root nameservers.

The root servers are operated by 12 different organizations. The root server is the first step where a DNS name is converted to IP address. It contains all the information about the global list of Top level domains like

1: Generic top-level domains: such as .com, .net, and .org.
2: Country code top-level domains: Such as IN, Ru etc.
3: Internationalized top-level domains: generally equivalents of country code top-level domain names written in the countries’ local character sets.
Basically, Root nameservers act as an index (first page) of a library where it points out different other racks in the library.

3: TLD nameservers:

These are server which holds the details of the domain based on a specific domain extension example .com,.edu,.org.
For example .edu holds all the details of .edu domains which are mainly used for education purposes. The root nameservers forward the request to the TLD nameservers and it searches for that particular domain in that category if it founds a matching it then forwards the request to authoritative nameservers.

4: Authoritative nameservers.

The request from the TLD nameserver reaches the authoritative nameserver which is the last step in the DNS lookup process.
The authoritative nameserver holds the details of the specific domain name example if we are searching google.com its authoritative nameserver hold’s the domain’s IP address, Mx records and other relevant DNS data. From here the request is forwarded to the respective server’s IP address.

What are the steps in a DNS lookup?

Step 1: A user types the example.com website in his computer’s web browser the query is travelled through the internet and received by DNS recursive resolver. The resolver keeps the browser request on hold and tries to find the matching IP address through the DNS lookup process.

Step 2: The recursive resolver searches in its DNS cache if found it returns the address from there if not found it queries the root nameservers and waits for the response.

Step 3: The Root nameserver responds with the details of the TLD since it is .com it returns the details of the .com TLD back to the resolver

Step 4: The resolver makes a request to the TLD.

Step 5: The TLD then respond with the authoritative nameserver details of the domain example.com.

Step 6: The resolver makes a request to the authoritative nameserver.

Step 7: Authoritative nameserver responds with the IP address of the domain name back to the resolver.

Step 8: Resolver responds to the web browser with the IP address of the domain name which is returned

Step 9: The browser makes an HTTP/HTTPS request to the IP address in order to load the webpage.

This completes the DNS lookup process.

This image shows all the dns lookup steps which had explained above.

Summary:

In this blog, we have covered the topic of DNS and how it works, We cannot cover all the details included in DNS as it is a very advanced topic.

Similar blogs:

Query the DNS records using the below articles.

How to use the Nslookup command?

How to use Dig command in linux?

Leave a Reply

Your email address will not be published. Required fields are marked *