DNS is a global system for mapping human-readable domain names to numeric IP addresses.
There are 4 types of DNS servers involved in the process and they work in harmony to complete the task:
recursive name server, root name server, TLD name server and last but not least authoritative name server.
A DNS resolver (recursive resolver), is designed to receive DNS queries and it is the first step in a DNS query.
The recursive server is like a middleman between a client and a DNS nameserver.
When it receives a DNS query, it will first look in its cache for the answer.
If it does not have the answer in its cache, it will send the request to a root name server, then a TLD name server and finally retrieve the answer from
authoritative name server for the domain name. The answer will then be returned to the web client.
During this process, the resolver will cache the answer for the length of the TTL.
If the same query is received again, the process of querying the authoritative name server will be skipped and the answer from the cache will be returned.
Recursive resolvers are also called public name servers and unlike authoritative name servers who only return answers for domain names hosted on it,
recursive resolvers return to all queries. Some of the popular public name servers are Google's 22.214.171.124 or 126.96.36.199.
The DNS Root Server extracts the Top Level Domain (TLD) from the user’s query.
The root nameserver responds by directing the recursive resolver to a TLD nameserver, based on the extension of that domain (.com, .net, .org, etc.).
There are 13 root servers worldwide, indicated by the letters A through M,
overseen by a nonprofit called the Internet Corporation for Assigned Names and Numbers (ICANN) which also manages all the domain names on the internet.
TLD name server
A TLD nameserver maintains information for all the domain names that share a common domain extension, such as .com, .net, .org etc.
For example, a .com TLD nameserver contains information for every domain name that ends in '.com'.
If a web client was querying a resolver for facebook.com, after receiving a response from a root nameserver,
the recursive resolver would then send a query to a .com TLD nameserver,
which would respond by providing details about the authoritative nameserver for that domain.
Authoritative name server
An authoritative name server provides original and definitive answers to DNS queries.
It does not provide cached answers that were obtained from another name server,
on the contrary, it stores the DNS records in its system and only returns answers to queries about domain names that are stored in its configuration system.