DNS

Osama Atif
3 min readDec 19, 2020

Domain Name System

What is all the fuss about DNS?

What does it do and how does it work?

Domain Name System — DNS for short is an integral part of our internet, this is the system that translates website names into IP addresses.

Servers on the internet use their own language to communicate with each other. A website like www.google.com has a domain name that we understand as humans but the computers know it for its IP address.

What does DNS do?

Think of DNS like a phone book of the internet, when we type in the address of a website — it looks up what the IP address of that website is.

You type in www.example.com into your web browser, your browser and your OS will check if they know where this website is.

They need the IP address to go to this website. If this website’s address is not in the browser’s cache, the computer will send a query to a DNS resolver to ask for more detailed info.

Types of DNS Servers:

  1. DNS Recursive Resolver/ DNS Resolver —This server is the middleman between client and DNS nameservers. It resolves your query by contacting other DNS servers and sends back the resolved result to the webclient.
  2. Root Name Server/RNS — This server operates at the root level of DNS, depending on the extension of the domain ie .com, .net, .org in the web client’s query, Root server replies the DNS resolver with the appropriate TLD Servers’ IP address.
  3. Top Level Domain/TLD Name Server — This server maintains the information of all the domain names that share a common domain extension such as .com, .net, .org. TLD Name server replies to the DNS resolver with the IP address of the ANS that has the requested website’s IP address.
  4. Authoritative Name Server/ANS — This server maintains the IP addresses specific to the domain names it serves. ANS replies to the DNS resolver with the IP address web client’s query.

Authoritative Name Servers of any website can be found with these CMD commands:

  • nslookup
  • Set query=ns
  • google.com
CMD Prompt with the output of nslookup command

The ns1.google.com is the primary server ns2.google.com and others are secondary servers in case the primary goes down.

Let’s see how DNS works in a bit more detail:

  1. You type in www.google.com. in the web browser

2. The computer needs the IP address to go to the website, if the website is not in the cache this query is forwarded to the DNS resolver which is chosen by your ISP.

3. DNS resolver checks its cache and replies to your query if it has the info. If it doesn’t have this info, it sends this query to the Root name server (RNS).

4. Root Name Server checks the extension of the website and replies to the DNS Resolver with the IP address of .com TLD server (TLD) that knows what the IP address of this .com extension server.

5. DNS Resolver then contacts this Top Level Domain Server. After looking at the query, the TLD Server provides the IP address of the authoritative name server (ANS) which knows the IP address of this particular website.

6. DNS Resolver then contacts this ANS to provide the IP address of this website, and the ANS replies back with the IP address of the website to the DNS resolver.

7. DNS Resolver stores this info in its cache and then sends this info back to your computer. This info is used by your computer to reach the website and display its contents on the screen.

This is how DNS works — all of these steps happen within a blink of an eye and you get your favourite website on your screen before you know it.

--

--

Osama Atif

Technology | Etiquette | Desi Culture | Books | Personal Opinion | Sports | Cricket