How does the Domain Name System work?

What is the Domain Name System?

The Domain Name System, or the DNS for short, is an organized namespace that uses a decentralized model. Its main purpose is to navigate queries, find the host they are searching for, and answer them quickly. The DNS came in the 80s to replace the inefficient HOSTS.txt file that had all the current hosts at the time. The DNS is superior thanks to the scalability and speed.

So, in short, the DNS is the service that maps domain names to IP addresses and serves to map services to hosts, verify different hosts and services, and more.

It has a hierarchical structure, in which on the top is the root, then TLD level, then secondary domain name, and finally subdomain. Each of the levels has a part of the information and directs to the next level that knows the rest.

What is DNS used for?

  • Makes the use of the Internet fast and practical.  
  • Resolves domain names to IP addresses. 
  • Locate and identifies hosts on the Internet. 
  • Locate and identifies services on the Internet.
  • Load balancing and redundancy. 
  • Service’s routing.
  • Verification of hosts, services, e-mails, and more.

Type of DNS servers

  • Root servers. They sit on top of the DNS hierarchy and answer requests for the TLD servers. It contains the root zone file, which has information about all the TLD that are available. 
  • The TLD name servers. They are authoritative name servers for each of the TLDs. 
  • Authoritative DNS name server. The authoritative DNS name server has the original zone file for the zone that it is responsible for. When queried, they will provide an authoritative answer that will prove the origin of the data. 
  • Recursive DNS name servers. These are DNS servers that are not hosting original zone files but only copies for a limited time. Their purpose is to answer queries if they have the answer in their cache memory or to pass the query to another name server, so the query can get answered.  

Authoritative DNS server vs Recursive DNS server

How does a DNS query work? 

  1. A user types a domain name, for example, google.com, and presses enter.
  2. If the user has visited the domain recently before, he or she will have it in his or her cache memory, and the query will get resolved. The users will be redirected to the IP address of the web hosting of the domain name. But if it is not in the cache, the query still needs an answer.
  3. The next stop is the DNS recursive server of the Internet Service Provider. In the ISP, there is a bigger chance that the answer could be found inside its cache. All the DNS queries of the ISP’s clients will pass through it, and the answers will be saved the TTL time the DNS records indicate. So if the answer could be found there, the result will be returned to the user.
  4. If it is still not there, the query will go on looking for an answer. The next stop is the root name server, which will check the last part of the domain name, the TLD. It will see which TLD it has, and it will redirect to the name servers for that TLD. In our case, the .com name servers.
  5. The user’s query will get to the TLD name servers, and they will point to the authoritative name server for the domain he or she was looking for.
  6. The authoritative name server for the domain name the user was looking for will finally answer with the A, AAAA, or both records, showing where the site is hosted.
  7. The user will finally be able to visit the site (google.com) that he or she asked for. The DNS records will be saved on the way on the recursive DNS servers and in the user’s device cache memory for the period the TTL value sets. 

Suggested article: What is DNS zone transfer?

Leave a Reply

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