DEV Community

Cover image for What is DNS?  What happens after you click

What is DNS? What happens after you click

mayankjoshi profile image mayank joshi Originally published at ・5 min read

DNS(Domain Name System) is a decentralized naming system that converts domain names(such as to its corresponding IP addresses.

Each device connected to the internet has a unique IP address, which is a 32-bit number for example IPv4), and remembering such an IP address is almost impossible. The solution to this problem was using English letters, as we humans beings are good at memorizing English words. Hence the concept of Domain Name came into the picture. Each domain name is a combination of English alphabets(generally) and points to an IP address.

To create a mapping between domain names and IP addresses, DNS(Domain Name System) was introduced. Now, whenever a user types a domain name, the DNS translates it into corresponding  IP addresses so browsers can load Internet resources.

Types of DNS Server

1. Root Domain Name Server

Root DNS servers are the first step in the process of resolution of Domain name into IP address. The mapping of a domain name to an IP address is a hierarchical process, and the distribution is done on the basis of DNS zones and Root DNS sits on the top of this hierarchy.

The root-level directly responds to the queries that are for the root zone or refer queries to appropriate TLD nameserver.
Generally, most of the queries are contains referring to TLD's hence Root DNS serves are not involved in name resolution.

There are a total of 13 root DNS around the globe starting with the letter a to m. Refer bottom for further insights.

2. Top-Level Domain (TLD) Server

Top-level domains are first-tier domains available for the use of the general public. They are installed in the Root DNS Server and all the other domains are the part of TLDs. For example, or are top-level domains, while or are secondary level domains.

Top-level domains are divided into two categories:

  1. Generic top-level domains (gTLD) - These are the domains that are not associated with any country. Example - .com, .org, .net, .int, .mil, .edu, .gov

  2. Country-code top-level domains(ccTLD) - These are 2 letter domains established for countries or territories. Example - .in, .uk, .to, .ca, .co, .us etc.

3. Authoritative DNS Server

It is the last stop for a DNS query and returns. It is a nameserver that has the original DNS records such as (A record, MX record, etc.).
The request to them reach from resolving name servers and they are the endpoint of any request. Note, they don't respond to recursive queries.

DNS Lookup

DNS lookup is a process by which an IP address(one of the DNS record) is returned for a domain name by a DNS server. The DNS is lookup is not only limited to returning the IP address, but it can also return all the records associated with a domain name(such as IP, IPv6 address or MX record, etc).

  DNS Lookup

The request to DNS resolver is a recursive request while all other requests in the above diagram are simple(non-recursive) queries.

The above diagram explains how DNS lookup happens and how DNS routes traffic to a website.

  1. A user opens a web browser, enters in the address bar, and presses Enter button.
  2. The request for is routed to a DNS resolver, which is typically managed by the user's Internet service provider.
  3. The DNS resolver forwards the request for to a root DNS server.
  4. The DNS resolver again forwards the request for, this time to one of the TLD name servers for .in domains. The name server for .in domains responds to the request with the names of the 2 or 4 (depending on the domain owner) name servers that are associated with the domain.
  5. The DNS resolver chooses a the authoritative name server and forward the request for to that name server.
  6. The website's name server looks in the hosted zone for the A record, to get the associated value, such as the IP address for a web server,, and returns the IP address to the DNS resolver.
  7. The DNS resolver for the ISP finally has the IP address that the user needs. The resolver returns that value to the web browser. The DNS resolver also caches (stores) the IP address for for an amount of time that you specify so that it can respond more quickly the next time someone browses to
  8. The web browser sends a request for using the IP address that it got from the DNS resolver. This is where the actual content is. For example, a web server running on a Google VM instance that's configured as a website endpoint.
  9. The web server or other resource at returns the web page for to the web browser, and the web browser displays the page.

List of Important DNS record types

  1. A - Returns a 32-bit IP address, commonly used to map a domain name to IP addresses.
  2. AAAA - Returns a host 128-bit IPv6 address.
  3. CNAME - Alias one name to another. The DNS lookup will continue by retrying the lookup with the new name.
  4. TXT - It is used to hold some descriptive text.
  5. MX - Maps Mail Exchange servers to a domain name.
  6. NS - Name server record is used to identify the authoritative DNS server for a domain.

Further Note -

  1. DNS server uses UDP(User Datagram Protocol) to serve requests.
  2. It works at port number 53.
  3. The DNS header size is 8 byte.
  4. DNS query consists of a single UDP request and a reply.
  5. DNS zone transfer is a process of replicating DNS databases across a set of DNS servers. DNS zone transfer uses TCP.
  6. To get the list of all the DNS records for a Domain name try $ dig any
  7. There are a total of 13 logical Root DNS servers available around the world with from as and the letter ranges from a to m.
    1. -
    2. -
    3. -
    4. -
    5. -
    6. -
    7. -
    8. -
    9. -
    10. -
    11. -
    12. -
    13. -
  8. ICANN is assigned authority to monitor the operation of the root name server DNS.

This post was published at I highly recommend you visiting the website.

Discussion (4)

Editor guide
digdugprophetie profile image
ادريس م

Would add that DNS uses UDP in general, but requires TCP to be open for certain transactions- notably when requests return large responses. Network admins only opening UDP53 toward the server can end up with user complaints that DNS fails intermittently.

mayankjoshi profile image
mayank joshi Author

Thank you for such a great insight.

musale profile image
Musale Martin

Very nice explanation.

mayankjoshi profile image