[Network & HTTP] Domain Name System (DNS)


4 min read

[Network & HTTP] Domain Name System (DNS)


In this article, I will be talking about DNS, which works just like a phonebook.

Other minor topics to be covered:

  • DNS servers involved in loading a webpage.
  • How DNS translates a domain name into an IP address (Full process of DNS lookup)

  • DNS Cache

  • DNS Record

What Is DNS?

When you go to facebook.com, you can do it by entering facebook.com in the URL bar, then the browser will direct you to the page. How can it be done so easily? Well, we are getting help from the Domain Name System (DNS).

DNS is a phonebook of the Internet. For example, you have a phonebook like this:

Do you memorize all the phone numbers of each person in your contact? - No.

You would go to your contact list on your phone, and then find the person's name that you want to call. DNS works just like this.

If you want to go to facebook.com, you just type that in the URL bar. DNS will translate that domain name into an IP address, which is a language that computers can understand. They can't understand our language.

For example:

Let's compare this one with the phonebook example above. It's not so different.

Without the DNS, we have to memorize all the IP addresses for each website we want to go to.

FOUR(4) DNS Servers for loading a webpage

  1. Recursive resolver

  2. Root nameserver

  3. Top Level Domain (TLD) server

  4. Authoritative nameserver

DNS Record Request Sequence - DNS Recursive Resolver gets request from client

Recursive Resolver

The recursive resolver is the first stop in a DNS query. When the browser sends a request for the IP address, the resolver first looks at the cache. If there is nothing about the request in the cache, the resolver sends a new request to a DNS root server. Moreover, the resolver stores the data from the authoritative server in a cache.

Now, cache is something that I will briefly explain later, but it is simply a storage. Think of a website that you visit quite often. Maybe YouTube or Amazon.

For those websites, the DNS will store the IP address in a storage, so that it does not have to go through all the steps of a DNS query.

DNS Root Server

When an uncached DNS query comes in, the first stop is the root server. Once the DNS lookup arrives at the root server, it goes down the hierarchy, which will be TLD server -> servers for specific domains -> (possibly subdomains if any).

DNS Heirarchy

There are only 13 DNS root servers.

TLD Server

Top Level Domain Server maintains information like .com, .net, .org, etc. We call them Top Level Domain (TLD). If you want to visit youtube.com for the first time, the DNS resolver will direct you to the root server. The resolver sends information from the DNS root server to the TLD server. Now, the TLD server knows that you want to go to youtube.com. The TLD server will then point to the authoritative nameserver for that domain.

Authoritative Server

The authoritative server provides the IP address for the specific domain name like youtube.com.

DNS Lookup Full Process

Complete DNS Lookup and Webpage Query - 10 steps

DNS Cache

Web browsers do caching by default. As I explained previously, caching is storing data in a separate storage, so it can be used later. With caching, we can reduce the amount of time spent on finding an IP address.

When you type in the domain name in the URL bar, the resolver first checks if the information requested is already in the cache. If there is, we do not need to go to the root server, TLD server and authoritative server. A lot of work are reduced. This will also help you to see the webpage more quickly because the IP address is already there. The browser just needs to render the webpage.

DNS Record

Did you find this article valuable?

Support Lim Woojae by becoming a sponsor. Any amount is appreciated!