Networking 101: What Is a DNS Query?
DNS is a topic which is often considered difficult to understand, but the basic thesis of it is actually not hard to grasp if explained correctly — which is the very aim of this article. The first fundamental point to grasp is that every domain in existence is linked to an Internet Protocol (IP) address. Even though loading up a webpage may seem like magic, it is not. If one were to open up their web browser, put www.example.com into the address bar and hit enter, their computer would then ask a server where to load that website from. In response, this server would respond with an IP address in order to be directed to the website of choice — that is what a Domain Name System (DNS) is.
In other words, when a user enters a website into the address bar, a translation must occur between the domain that the user types in (www.example.com) and the IP address which the domain is linked to. The task taking place behind the scenes here is referred to as a DNS name resolution. The way in which this works can be compared to how a post code is used in combination with a door number in order to be directed to a literal geographical location. The reason for this is because long digits of numbers (such as 93.184.216.34) which is the IP address for the domain in this scenario would be too difficult for human beings to memorise or remember for each and every website. In order to solve this, the Domain Name System (DNS) was created to operate as a directory for the internet. This particular process is known as a DNS query.
However, it is important to note that there are three main types of DNS queries and this is where it becomes slightly more technical. These three types being: recursive, non-recursive, and iterative — which may be explained in the following way:
1. Recursive DNS query — This form of DNS query will attempt to obtain a DNS name resolution by connecting to a Recursive DNS server. Most of these are ran by Internet Service Providers (ISPs) and will be the default for the average user unless they have changed this. Once a computer connects to the assigned Recursive server, it will ask “what is the IP address for this website?”. The first thing that the Recursive server will then do is check to see if the IP address for the URL in question can be located within its local cache. This would be the case if you had visited the website before, as the IP address would be stored in a local repository. If so, the user will successfully be able to load the website. However, if this is not the case and it does not exist within the local cache then the Recursive DNS server will attempt to obtain the IP address through other means.
Fortunately, most ISPs usually provide a Recursive DNS for this very purpose which contains its own cache system so the user does not have to rely on having visited the website before or local cache. The next step in the recursive process would involve trying the request over and over until a response is given. This query is ran multiple times to check if the DNS query can be filled from its own cache or by querying other trusted DNS servers. It moves down its list of trusted DNS servers in a hierarchical order to ensure that the most important DNS servers are checked first. Once this process is complete, the user will either be returned with an IP address, a uniform resource locator (URL) or an error message stating that the request (site) does not exist.
2. Non-Recursive DNS Query — This form of DNS query is able to respond immediately as the DNS Resolver already knows how to obtain the answer to the query. The reason for this is because the DNS record will either be stored in the local cache or it will query a DNS name server which is authoritative and definitely holds the IP address for the hostname. In other words, a response is immediately returned to the client because unlike Recursive and Iterative queries, there is no need for additional rounds of queries.
3. Iterative DNS query — This form of DNS query works by allowing the client to directly communicate with each DNS server involved in the lookup. This is in contrast to Recursive DNS queries which use a DNS server to communicate with other DNS servers. Once a server has received an iterative query it will either return the IP address of the requested host name, or it will issue a referral which means that it will produce the address of a DNS server that should know. The client is then able to directly issue an iterative query to this referred server.
In summary, this article has defined what a DNS is and introduced the concept of DNS queries. With that being said, there are still numerous other aspects of DNS such as Zones, Records, Load Balancing, and Scavenging — which one should familiarise themselves with in order to gain a more technical and comprehensive understanding of DNS as a whole.