Did you know that Domain Name System (DNS) is one of the foundations of the internet? If not, don’t worry; most people outside of networking don’t know about this system. Yet, you use it every day to do your regular job, while checking emails or browsing the net—without realising you are using it. But what exactly is DNS, and how does it work. Let’s find out.

What is DNS?

In its most basic sense, DNS is nothing but a directory of names that match with numbers like IP addresses, which is used by computers and servers to communicate with each other. Think of DNS like your phone’s contact list; it tallies users’ names with their IP addresses. You must understand three things when learning about DNS: DNS, IP Address, and Domain Name.

Domain Name System

Domain Name System, or DNS, is often referred to as the phonebook of the websites. DNS’ job is to translate the domain name you are looking for into IP addresses, making it possible for your browser to load the information you are looking for. To understand this fully, you also need to know what IP address and domain name are.

IP Address

An Internet Protocol address or IP address is a set of numbers that act as the binary identifier for devices across the internet. IP addresses are unique to each device, and they are usually arranged into four sets of digits, like 87.65.43.21. When you use the internet, the server or the website uses your device’s IP address to identify it.

Domain Name

On the other hand, each website has a unique domain name; it is the information you enter into the search bar when looking for a specific web browser, for example, reddit.com or wikipedia.org. A domain name is used instead of an IP address to identify websites because it is easier to remember words than a complex string of numbers.

Even the website you are looking for has an IP address, and you can access the web page by simply typing the IP address in the search bar. But isn’t it a lot easier to type the website’s domain name instead of the IP address?

While it’s easier for you, computers and servers cannot understand domain names as they strictly rely on binary identifiers like IP address. Thus, DNS’ job is to convert the domain name that you enter into an IP address, allowing the various devices to communicate with each other.

How Does DNS Work?

The process of DNS resolution is relatively easy to understand, where a domain name is converted into IP address, which is more computer-friendly. Here’s an easy way to understand how DNS works.

When you try to access a website using your browser, you first type in the website’s URL or domain name into the search bar. The browser sends a query to the DNS cache instantly to see if you have looked up the website in the past.

If the browser does not find any past DNS records, a query is sent to the local DNS server, which is typically your local ISP’s server. If the records are not found on the local server, then the query is sent forward to one of the root nameservers, which are designated servers that store DNS data.

Once the DNS records are found, your computer quickly caches them.

Then, a connection between your device and the website server is established and opened, and the website is loaded.

DNS Name Records

As mentioned, DNS records are stored across caches and servers, and there are many different types of records. These records keep the internet running smoothly, and they are responsible for making domain names point to specific IP addresses. Here are some of the most commonly used and most important types of DNS records.

Name Servers

Before we move to the types of DNS records, you should first understand what name servers are. Name servers are often confused with DNS records, but both are pretty different. DNS records contain the actual information that your browser or device needs to interact with the online world.

There are two major types of name servers—local, located on your ISP’s server, and root, designated at various locations across the globe. These name servers store the DNS records that your browser or device uses to extract information for its inbuilt DNS cache.

A Record

A record is the most common type of DNS record used on the internet, and it directs a domain to an IPv4 address. All you need to set up an A record on your domain is an IP address for it to point to.

A records are usually categorised with AAAA records, which operate exactly as A records. The only difference between A and AAAA records is that the latter points to an IPv6 address.

CNAME Record

Another commonly used type of DNS record is the CNAME record, and this record is used to link a subdomain to other A or AAAA records. The only downside with CNAME records is that they can’t be used to place on root domains; they can only be used for subdomains.

MX Record

Mail eXchange, also known as MX, is the record that directs emails coming to your domain. If you want to provide your employees and clients with emails on your domains, for example, [email protected], then you need to use MX records paired with your mail server. One great benefit of MX records is that they allow you to set varying priorities and redundancies as long as you have multiple mail servers configured for them.

TXT Record

Another popular kind of DNS record used on the internet, especially on various applications, is the TXT record, which allows you to hold any textual information on your domain or subdomain. Applications in particular use TXT records to verify the information about the service your website is using, like SPF records, DomainKeys, or DKIM. However, TXT records are limited to only 255 characters.

The Four DNS Servers that Load a Webpage

Whenever you log onto a website, a process of DNS resolution occurs that converts the website’s domain name into an IP address that is easier for the computers and servers to read. This DNS lookup process happens behind the scenes of the website within a few seconds, and the query goes through four servers before the webpage is shown. Here are the four DNS servers that are essential for loading a webpage.

DNS Recursor

DNS recursor is the first level of server; it is designed to accept DNS queries directly from your device or web browser. Mostly, the DNS recursor makes additional requests to subsequent DNS servers to satisfy your original DNS query. You can think of DNS recursor as a librarian that helps you find a particular book in a library.

Root Nameserver

After the DNS recursor comes root nameserver, this is a root server that initiates the translation of human-friendly domain names into IP addresses that are computer friendly. Continuing the librarian analogy, think of root nameserver as the index that the librarian will use, pointing them to different shelves of books. Root nameservers serve as a reference to specific locations.

TLD Nameserver

The third DNS server that your query passes through is the TLD nameserver. Here, TLD stands for a top-level domain, and it is the next step in search of the IP address of the website you want to access. TLD server hosts the last portion of the domain or hostname, like .com, .au, or .org. You can think of TLD nameserver as the specific shelf in the library where your book is located.

Authoritative Nameserver

The final server your DNS query goes through is an authoritative nameserver. If the authoritative nameserver has the information requested, it will return the correct IP address to your query; if it does not, it will redirect the query back to the DNS recursor that initiated the request. Authoritative nameserver acts as the directory of books on a specific bookshelf in the library.

The Difference Between an Authoritative DNS Server and a Recursive DNS Resolver

Both authoritative DNS server and recursive DNS resolver refer to groups of servers that make up the DNS infrastructure. However, both perform different roles and are located in different locations of the DNS query process. To put it simply, a recursive DNS resolver is located at the beginning of the DNS query, and an authoritative DNS server is located at the end. Here’s more on them in detail.

Recursive DNS Resolver

A recursive DNS resolver, a computer, is responsible for responding to recursive requests from your device or browser and tracking down the DNS record. The resolver functions to resolve your DNS query by making a series of requests that will direct it to the authoritative nameserver at the end of the tunnel, where it will retrieve the IP address of the website you are trying to access.

You might think this takes a lot of time, but the entire process happens within a few seconds. More often than not, the recursive DNS resolver does not even need to make multiple requests; it finds the specific information on the first try. Here is where DNS caching helps a lot as it allows the resolver to short-circuit the requests.

Authoritative DNS Server

If recursive DNS resolver is the first step in resolving your DNS query, then the authoritative server is the final step in the process. This server is what actually holds the DNS resource records your browser is looking for. This server allows your web browser to reach the IP address that’s needed to access the website you are looking for.

Since the authoritative server is the final source, it does not need to extend the query to another source or server to translate the IP address. However, if your DNS query is for a subdomain, it may need to extend the query to the authoritative nameserver that is holding the subdomain’s CNAME record.

What are the Types of DNS Queries?

When you search for a website in your browser, the browser sends a series of codes to the DNS servers requesting the required information. These codes are called DNS queries; they help the servers recognise what information you are looking for. There are three basic types of DNS queries, which are as follows.

Recursive Query

A recursive query is where your browser provides a domain name. The DNS resolver must revert with the correct IP address; hence, with recursive queries, the nameserver either responds with a relevant resource record or an error message. The process starts from the DNS root server up to the authoritative name server that holds the IP address you are looking for.

Iterative Query

On the other hand, an iterative query is where the DNS client provides a hostname, and the DNS resolver has to return the most relevant answer it can find. For example, if the resolver has the records in its cache, it will revert them; if not, the resolver will forward the query to the root server or authoritative server.

Non-recursive Query

The third kind of DNS query is the non-recursive query, where the DNS resolver already has the resources your browser has requested. As soon as your browser initiates a query, a non-recursive query immediately returns the correct answer that is already stored on its local cache. Even if it does not have the IP address in its local cache, it directly forwards the query to a DNS name server.

What is DNS Caching?

DNS cache is a library of IP addresses and domain names stored on your computer. The DNS cache makes it easier for your browser to load the internet resources without constantly sending DNS queries to the respective servers for the correct IP addresses. Hence, the purpose of DNS caching is two-fold—one, to speed up the DNS requesting process; two, to reduce the DNS bandwidth and traffic on the internet.

The DNS cache is just like any other type of computer cache; it stores the data on a temporary basis that is easily accessible by the browser and other online applications. DNS cache can be stored in various locations, but the two most common DNS caching locations are the browser and operating system. More on both in the following section.

Where Does DNS Caching Occur?

DNS cache can be located at various locations, and each cache would ideally store relevant and updated DNS records as per the time-to-live criteria. However, the two most common DNS caching sites are your internet browser and the operating system.

Browser DNS Caching

Modern web browsers, be it Opera, Google Chrome, or Apple Safari, are designed to store temporary DNS cache records. The purpose of browser DNS caching is quite straightforward; the closer the DNS cache is located to the internet browser, the fewer steps the browser would take to find the correct information.

Instead of sending out a DNS query to the local server every time you look something up on the internet, the browser instead sends the first query to the browser DNS cache. If the required records are not found, then the browser initiates a DNS query to nameservers.

The problem with browser DNS caching is that it can significantly slow down the web browsing experience if the cache builds up. If the cache is outdated, it can start returning various connection errors on your browser. So, it is always a good idea to clear your browser DNS cache once in a while to keep it updated and relevant.

Operating System (OS) Level DNS Caching

Another most common location where DNS caching occurs is the operating system of your device. This is also the second and final location where your browser will check for DNS cache records before sending out a query to name servers. The process within your system that handles the DNS query is called the DNS client or a stub resolver.

When the DNS client gets a request from the browser, it checks its own cache records; if the information is not found, the client sends out the recursive DNS query to a DNS recursive resolver ISP’s server.

Recursive Resolving DNS Caching

Additionally, each DNS recursor also contains its own DNS cache; it caches any IP addresses that it comes across to use for upcoming DNS requests. This is the third type of DNS caching that usually occurs at your ISP’s servers, but it is not as common as the previous two DNS caching locations.

Every computer connected to the internet relies on DNS and its network of servers, and without DNS, the internet would be quite tricky to use. However, thanks to DNS, it makes your web browsing experience smooth and quick.

Stay tuned to know more about DNS and other behind the scenes technologies that amplify your web user experience.