What is a Domain Name System and How it Works?

Think of a phone directory and the number of listings it has. Did you ever try to remember a whole bunch of list other than a few phone numbers which belong to your family?

It might sound complicated as it is nearly impossible to do so.

However, you must be quite aware of lots of website names. This is because a Domain Name Server turns an IP address into a more human-friendly name which is easier to read, understand and remember.

Hence a Domain Name System simply converts these names into numbers which makes it easier to communicate with a computer system. Therefore an IP address 176.317.34.196 with the help of a DNS may turn this entire number into a more human-friendly and, easy to remember the name (such as www.thevpnexperts.com). This acts vice versa.

But here’s the catch, what numbers or IP address go with which name is decided by a DNS. And in the case of a user, this DNS server is provided ISP (Internet Service Provider). Therefore an Internet Service Provider finds an IP address for your desired domain name and renders the results on your screen in the form of a website.

To make it more understandable, the process always ensures the following takes place:

  1. You type a web address in your browser, which passes on the details to the ISP regarding the website you are trying to access.
  2. Your computer will contact the DNS server which then brings the IP address for that domain name.
  3. The time when this activity happens is also recorded.

Therefore an ISP can see the following:

  1. Your IP address.
  2. The website you are trying to visit.
  3. The time you have conducted that activity.

Types of DNS Servers and Records

types-of-DNS-servers

In order to resolve an IP address into a hostname (website name) there are 3 types of Domain Name Servers in use:

  1. DNS Resolver
  2. DNS Root Server
  3. Authoritative DNS Server

1. DNS Resolver/Recursive Resolver

The recursive resolver is responsible for receiving the Domain Name Server queries (DNS queries) which include the website name and tracks back the IP address for that hostname.

2. DNS Root Server

It begins with the root server, travelling from hostname to the IP address. For example, www.thevpnexperts.com; the details are provided for .com via TLD Name Server. There are in total 13 root servers across the globe.

3. Authoritative DNS Server

It is the last step in the whole journey where the name server query is given the hostname, which returns the correct IP address to the DNS Resolver.

How Does DNS Work?

In a typical DNS query, the URL entered by the user must pass through four servers to retrieve the corresponding IP address. These servers work together to ensure the correct IP address is provided to the client. The four servers involved are:

DNS Recursor

Also known as a DNS resolver, the DNS recursor receives the query from the client and communicates with other DNS servers to obtain the correct IP address.

Once it receives the query, the recursor acts like a client itself, sending requests to the other DNS servers: root nameservers, top-level domain (TLD) nameservers, and authoritative nameservers.

Root Nameservers

The root nameserver is responsible for the DNS root zone on the internet. It handles requests for records within the root zone and responds by providing a list of authoritative nameservers for the correct TLD.

TLD Nameservers

A TLD nameserver stores the IP addresses of second-level domains within its specific TLD. It returns the website’s IP address and directs the query to the appropriate domain nameserver.

Authoritative Nameservers

The authoritative nameserver provides the definitive answer to the DNS query. There are two types: the primary (master) nameserver and the secondary (slave) nameserver.

The primary nameserver holds the original zone records, while the secondary nameserver maintains an exact copy, helps distribute the server load, and serves as a backup in case the primary server fails.

Types of DNS Queries

In a standard DNS lookup, three main types of queries occur. By using a combination of these, the DNS resolution process can be optimized, minimizing the distance data needs to travel. Ideally, cached records will be available, allowing a DNS server to return a non-recursive query.

1. Recursive Query

A recursive query occurs when a DNS client requests that a DNS server (often a recursive resolver) respond with either the requested resource record or an error message if the record cannot be found.

2. Iterative Query

In an iterative query, the DNS client allows the server to provide the best possible answer. If the queried server cannot find a match, it will return a referral to another DNS server that is authoritative for a lower-level domain. The client will then query the new server, continuing this process through additional servers until an answer is found or an error occurs.

3. Non-Recursive Query

This type of query happens when a DNS resolver client requests a record from a server that either holds the record authoritatively or has it cached. Servers often cache DNS records to reduce bandwidth usage and minimize the load on upstream servers.

How to Conduct a DNS Leak Test?

Only if you have sound knowledge about how the internet and domain name servers work will conducting a DNS leak test come in handy. In order to conduct a DNS leak test, paste the URL https://www.dnsleaktest.com/; in your Chrome, Firefox, or any browser you are using.

Usually, your ISP dedicates their users a DNS server which is controlled and logged by them. And obviously, you wouldn’t want your activity to be monitored or recorded. This DNS server is contacted by your computer whenever you try to open a website on your desktop or mobile browser.

dns leak test

The standard test will determine your IP address, hostname, your current location and the location of your ISP. If you are using a VPN service, then you must ensure the test does not show your current location but the virtual server location provided by the VPN service you are using.

How to Ensure Protection if a DNS Leaks Data?

So far, you must have the idea that a lot of what you do over the internet is either logged or monitored willingly or unwillingly. Therefore, the only two possible ways to ensure protection if your DNS leaks data are:

  1. Using Smart DNS
  2. Using a VPN

1. Using Smart DNS for encrypting your internet activity

Smart DNS is a kind of proxy that is attained by paying to companies who direct a user’s traffic through a virtual location to access the content the user is trying to access.

But, this does not change or mask the user’s IP address from the ISP.

2. Using a VPN to protect from DNS leaks

Virtual Private Network is a software program that provides security and privacy. When a VPN is in place, the IP address and the DNS server dedicated to a user are masked by a virtual location picked by the user. Therefore a VPN creates an encrypted tunnel between the user and the ISP, and whatever happens within the tunnel stays in the tunnel.

However, among the two, VPN and Smart DNS, a VPN service always comes in handy when privacy, encryption, and geo-blocking are major concerns. But a service like this will slow down your internet speed as your entire traffic will be routed through a totally different location.

Whereas a Smart DNS does not ensure privacy and security but will help in unblocking geo-restricted content without affecting your connection speed. This is because a Smart DNS will only route certain parts of your internet traffic through a Domain Name Server.

It must be noted that not always act as a silver bullet while protecting your identity. As found out by a paper published in 2015;

“A Glance through the VPN Looking Glass: IPv6 Leakage and DNS Hijacking in Commercial VPN clients”

It clearly suggests that there are IPv6 leaks and DNS hijacking possible within popular VPN services. Therefore, do your due diligence in picking up a secure VPN service for maximum online privacy.

What is DNS Caching?

DNS caching refers to the practice of temporarily storing data in a location that enhances performance and reliability when retrieving data. By caching DNS data closer to the requesting client, DNS queries can be resolved more quickly, reducing the need for further queries down the DNS lookup chain.

This leads to faster load times and decreased bandwidth and CPU usage. DNS data is stored in various locations, each holding the records for a specified duration based on the time-to-live (TTL) value.

Browser DNS Caching

Modern browsers typically cache DNS records for a set time to improve performance. The closer the cache is to the web browser, the fewer processing steps are required to check the cache and resolve the correct IP address. When a DNS request is made, the browser’s cache is checked first for the record.

For example, in Chrome, you can view the status of your DNS cache by visiting: chrome://net-internals/#dns.

Operating System (OS) Level DNS Caching

The DNS cache at the operating system level serves as the second and final local checkpoint before a DNS query is sent beyond the local machine. The component responsible for managing this process is typically referred to as a “stub resolver” or DNS client.

When an application makes a DNS request, the stub resolver checks its local cache for the record. If it’s not found, the resolver sends the query (with a recursive flag) to a DNS recursive resolver located within the Internet Service Provider (ISP).

About Sebastian Riley

Sebastian Riley is a cyberlibertarian activist and an internet freedom fighter who strongly believes in an unsegregated and uncensored internet. With a cybersecurity degree, Sebastian is a professional bug hunter and a freelance opensource penetration tester.