Last updated on September 16, 2020 by Sarmed Rahman
Domain Name System (DNS) is one of the most critical services in the Internet. Without DNS, we would not be able to access the web. Before going into the details on how DNS works, a little on the background may be helpful.
When you are accessing, say, Google, your traffic originates from your computer, goes through the backbone of your ISP, and then their own upstream provider and so on; until it reaches Google's network. In the TCP/IP-based current Internet, the transit communication from your computer all the way to Google's network is driven by a set of intermediate routers based on the IP address of the destination web server of Google.
This means we need to know the IP address of Google's web server to access Google service. However, it is almost impossible for us to keep more than hundreds of IP addresses in our memory. What if there could be a mechanism to map IP addresses to domain names that are easy to remember? That is where DNS services come in, which keep directories of all domain names and their associated IP addresses. So if we want to communicate with a particular web server, we can use its domain name, say, www.example.com. DNS server then handles the translation of the domain name to its IP address, so that our computer can communicate with the destination web server with the IP address.
Before we get into the details of how DNS actually works, we need to understand some terms used in the industry.
The following section is a long list of definitions. To have a firm grasp on the operation of DNS, it is important that we understand them. However, if they are too much to digest all at once, especially for the beginners, you may read through them once and move on to the next part. You can come back later to go over the hierarchy again. Believe me; they will start to make sense as the pieces fall together.
All DNS names are hierarchical and are typically divided into 3 major parts i.e.,
host.domain.tld. For example, for www.example.com, the part www is the host part, .example is the domain part, and .com is the top level domain (TLD). The following sections explain these in details.
The root servers and root zones are amongst the highest order in the hierarchical world of DNS. The root zones maintain the top level domains. The servers that are used to host root zones are called root servers. There are 13 sets of root servers, which are named as
d.root-servers.net up to
m.root-servers.net. The number 13 refers to number of entities and not to the actual number of servers. Each entity may contain hundreds of devices in their network for clustering, load balance and redundancy. The root servers share a distributed database and communicate with each other for updates.
A top-level domain or TLD is the rightmost part of the name, e.g., .com, .org, .net, .gov, .mil. All domains have to be registered under a top level domain. TLDs are maintained by Root Zones.
A domain is a "string" registered under a TLD to be used by an organization/user as a part of the name. The DNS is open to the users starting from domain and moving downwards in the hierarchy. In the name syntax, the domain part is written in the left of TLD. For example, in www.example.com, the part example is the domain name. Domains are maintained by Authoritative Name Servers i.e., DNS servers maintained by the user/domain.
A sub domain is an optional parameter and is written on the left of the domain. A user is free to delegate sub domains within a domain. The sub domains records are kept in the authoritative name server maintained by the domain. For example, in
www.branch-1.example.com, the part
branch-1 is actually a sub domain.
Hostname is typically the leftmost part of the name, and indicates the actual server that is hosting the services. The admins have full access to this part, and can delegate names as they want. For example, in
ftp.example.com, the parts
ftp are hostnames, and indicate actual web server and ftp server.
The Authoritative Name Server of a domain is responsible for keeping all DNS records that are relevant to the domain. Naturally, it is impossible, as well as inefficient for the root servers to contain all DNS mappings and records for every domain in the world. Instead, the authoritative name servers for each domain should contain all the records for the respective domains. The root servers contain information about the authoritative name servers for each domain.
Let us assume a user is trying to access the site www.example.com. After the user typed the URL in the browser and hit enter, the page is loaded seamlessly in the browser. To make that happen, the following events take place behind the scenes.
1. The user computer checks its own DNS cache for the IP address. If it is not found, the user forwards a query to the configured local DNS server, typically the DNS server operated by the user's ISP.
2. The local DNS server checks its own cache for the IP address to check whether it already knows the answer. If it is not found, the local DNS server queries the root servers for the authoritative name servers for the domain. This type of query is called a recursive query. As the TLD for the domain is .com, the responsible root servers should be able to answer the query.
3. The root servers reply with necessary information about the authoritative name servers.
4. The local DNS server now queries the authoritative DNS servers of example.com directly, which should have all DNS records within the domain.
5. The authoritative DNS server of example.com answers the query by providing the IP address 100.100.100.100 for the host WWW.
6. The local DNS server stores the information in the cache for future reference, and returns the IP address to the original user.
7. The user computer stores the IP address in its DNS cache as well. Then the web browser generates an HTTP request to the WWW server of example.com located at 100.100.100.100.
8. The WWW server of example.com happily responds to the query, and sends the page to the user.
To sum up, surfing through the Internet is very easy thanks to DNS. Underneath it, however, a lot of activities take place in the background. The Internet that we know and love today would collapse without it.
Hope this helps.
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.