Continuing with our Former Post on Domain Name System(DNS), now we will be discussing about the Distributed Domain Name System(DDNS) and the DNS caching in this post.
To deal with millions of Internet users throughout the globe, a single DNS server is not capable of mapping each and every hostname to every IP address in a Computer Network. Thus, a network of DNS known as Distributed Domain Name System is formed. This Domain Name Systems are structured in a hierarchical format. There are basically 3 types of DNS servers- Root Servers, Top-level Domain Servers and Authoritative Servers. Lets have a look at this diagram.
1. Root DNS Servers:
There are 13 root servers throughout the globe. They are named from A to M. Most of these are located in North America. This doesn’t mean that there are only 13 root DNS servers. This indicates that there are 13 authoritative companies that look after these root DNS servers and most of these companies are in North America. Because root DNS servers are replicated at various places to distribute the load and provide better services. The number of root DNS servers is around 247 that are spread throughout the world.
2. Top Level Domain (TLD )Servers:
These servers are responsible for the Top level Domain Names such as .com, .org, .edu, .gov etc. and the Top level Domains of a country such as .in, .us, .fr etc. The Two companies, 1st is Verisign Global Registry Services maintains the TLD servers for com top level domain and 2nd one is the Educause, that maintains the edu top level domains.
I recommend you to read IANA TLD 2012 to get more knowledge on Top Level Domain Servers.
3. Authoritative Servers:
A company or a university can maintain their own authoritative DNS servers. The organisation having its host accessible publicly to the Internet can provide an authoritative DNS servers.
- Here is a Map showing all the DNS servers throughout the Globe.
There is also one more type of DNS servers. These are known as Local DNS servers. Every Internet Service Provider (ISP) has a local DNS. Whenever a host connects to a ISP, the ISP provides it with the IP address of its local DNS server. When a host makes a DNS query , the query is 1st send to the local DNS, which forwards it to the upper DNS server hierarchy.
Let us discuss an example that will make you clear with the working of the DNS servers in a hierarchy.
Let us suppose that a host ec.school.edu wants the IP address of the cs.stanford.edu. The local DNS server of ec.school.edu is dns.school.edu and the authoritative DNS server of cs.stanford.edu is dns.stanford.edu. The host ec.school.edu will 1st send the DNS query to its local DNS server. The query is to translate the hostname cs.stanford.edu into its IP address. The local DNS server forwards the query to the root DNS server.
The root DNS notes that the query contains the .edu suffix, and returns the local DNS server a list of IP addresses for TLD servers responsible for .edu. The local DNS server then re-sends the query to a TLD server. The TLD server notes that query is with .stanford.edu suffix. Thus it responds with the IP address of authoritative DNS server for the Stanford University, named dns.stanford.edu. The local server now sends the final query to the dns.stanford.edu, which responds with the IP address of the cs.stanford.edu. You can see that, to obtain the IP address for 1 hostname, 8 DNS queries are being sent. Thus to reduce these queries DNS caching is used, that I will tell you later in this post.
Lets clear it with the help of a figure :
Here we have observed that the TLD server knows the address of the Authoritative server, but in real world , it might not be the case. For example : Stanford University has a DNS server dns.stanford.edu. And the individual departments in the University might have their separate DNS servers for the departments, that will act as Authoritative Servers for the hosts in that department. Now the local server will send a query for cs.stanford.edu to the Stanford DNS server, dns.stanford.edu. The Stanford server will now return the IP address of the Authoritative server of CS department, dns.cs.stanford.edu. Finally the local server will sends a query directly to the authoritative DNS server of CS department, and it will return the desired IP address of the host. In this case, there will be total 10 DNS messages sent.
A figure for this scenario:
There are particularly 2 types of queries.
i) Recursive Query
ii) Iterative Query
The query sent from ec.school.edu to dns.school.edu is recursive , as it is send on its own behalf. But the other subsequent queries are iterative, since the replies are directly returned to dns.school.edu. In Figure 1 and Figure 2, only the query send from ec.school.edu to dns.school.edu is recursive, rest all other queries are iterative.
Diagram for Recursive Queries:
- In an Internet world, the queries follows the Figure 1 and Figure 2 pattern.
DNS Caching :
DNS caching is an important aspect of DNS. It is highly used in the real Internet world to reduce the delays and to reduce the number of DNS queries running around the Internet.
Let me take the above Stanford example and you will understand DNS Caching very well.
Here ec.school.edu queries to Local DNS server to get the IP address of cs.stanford.edu. Now after completing this request, the Local DNS server will save this mapping in its own memory. Therefore, if any other host from the school , queries for the cs.stanford.edu again, then the local server can reply from its own memory at much faster pace. This phenomenon is known as DNS Caching. The Local DNS servers can cache the mappings of TLD servers also, in order to bypass the root servers.
But this caching will be removed after some period of time , as mapping between the hosts and IP address is not permanent.
Thank you for reading this article.