How DNS Resolutions works
Understanding how DNS works and basic dig commands

Introducing the DNS and its Duties
Introducing DNS ~ The Domain Name System. The DNS acts as the phonebook of the internet, converting text-based URLs that we use to look for specific websites, into numerical (machine-readable) IP addresses. Thanks to DNS and its roles, we do not have to memorise the IP address of every single webpage on the internet. Rather, we ask the DNS, and it returns to us what we are looking for. This duty of the DNS, i.e. translating a domain name, into its IP address, is called Name Resolution.
Introducing dig
The ‘dig’ command (Domain Information Groper) is a tool that helps ask the DNS name servers for any information. The dig is also a command-line tool and can be used to work with / diagnose several DNS records.
The general structure of a dig command:
dig [@server] [domain] [query-type] [options]
@server: This allows you to specify the DNS server you wish to query [Optional: If unspecified, it uses the default server]
domain: Domain name
query-type: Type of DNS record (E.g.: A, AAAA, MX etc.) [Default: A record]
options: You can specify various options to format your query results (E.g. +short, +trace etc.)
Example dig commands
It returns a list of authoritative name servers for the DNS root zone.
‘ . ‘ represents ‘root’.
NS represents ‘name server’.
Root name servers are the root or foundational levels of the DNS hierarchy. They are the starting points of the name resolution process, and know where to find the Top-level-domain name servers for each webpage.
It returns the list of root level servers specifically managing the top level domain ‘.com’.
- A top level domain acts as the next stop after the root level during the name resolution process, in the DNS hierarchy. It is generally what follows the final dot after a domain name. E.g.: In hashnode.com, ‘.com’ is the Top Level Domain. They know which authoritative server handles the specified domain.
It returns the authoritative name servers for google.com.
- Authoritative name servers are the final step in the DNS look up process and it acts as the authority storing the DNS records that ultimately resolve to the corresponding IP address.
It returns the actual IP address that corresponds to google.com. (It returns the A record for an IPv4 address, and AAAA record for an IPv6 address).
Behind the hood
The story begins when the user types the URL into the browser.
“https://www.google.com”
The browser checks its cache & then its Operating System cache as well initially to resolve this URL into its IP address.
If it does not get the IP address from there, then the query is sent to the DNS resolver.
The DNS resolver first checks its cache.
If it is not available, it reaches out to the root name server. The root name server most likely has the details of the name server for “.com”, and it returns this information to the DNS resolver.
The DNS resolver reaches out to “.com” Top Level Domain name server, which returns the Authoritative Name Server details of google.com to the DNS Resolver.
The DNS resolver reaches out to the authoritative name server of google.com, which returns the IP address of google.com to the DNS Resolver.
The DNS resolver returns this IP address to the Operating System, which then returns it to the browser.
And that detailed process is how our searches for a website, quickly resolve into their IP address, where we finally find a web page on the internet!
References:
Comments
Join the discussionNo comments yet. Be the first to comment.

