DNS stands for Domain Name System. Think of DNS is equivalent of Contact book. How the contact book works, if you want to call your friend there are 2 ways. you will open contacts list and search his name and call him, or you will type his phone number directly if you remember it.

On the internet every device has a unique IP address, to access any device we need to know its IP address, without IP address we can’t access. When we type any domain name in the browser like google.com in the backend IP Address is being used to access this website.

How Does Computer know the IP of other Computers?

That’s where the role of DNS Servers came into place, DNS Server Stores the IP Address of every domain name into its database/storage, When we hit URL into browser it sends request to the DNS Server, then it searches in its database and returns IP Address of that domain and then again our computer uses this IP Address to connect with the device.

how dns works
how dns works

Low-Level Overview of How DNS Server Works

Lets Dive litter bit deeper, There are 4 type of DNS Server.

  1. Recursive DNS
  2. Root Name Server
  3. Top Level Domain (TLD) Server
  4. Authoritative DNS Server

If the computer does not know the IP Address, then a DNS Query happens, it first tries to find its IP address into its local storage and in case of windows OS it searches hosts.txt file, if not found then it sends a request to Recursive DNS (provide by your local internet service providers), it stores the IP Address of domain name temporary, it updates itself after a certain period of time, because some website IP address changes and it provides the latest IP address of that website. For example, google.com is the most widely used domain name it stores its IP address in its cache.

if the IP Address is not found from recursive domain name server then it sends a request to root NS, then the root NS checks the last part of the requesting domain name. for example google.com, it checks .com, and sends the IP of TLD NS and tell that get IP from TLD Server, then TLD NS find the first part of the domain like google and turn back its ip, if still not found then the Authoritative NS must have the domain IP address.

After finding the IP Address the Recursive NS saves it for future use to save request timing of domain.

how dns works low level view
how dns works low level view

Finally our computer got the IP address of the domain and then it sends request to the server.

Is DNS Necessary ?

Yes, although we can visit any website using IP, like if we hit 172.217.169.238 into the browser google will open. but can you remember IPs of all other websites ? No, because human can remember names instead of numbers. It is easy to remember amazon.com, google.com , yahoo.com but not 1.2.3.4 bla bla.

That’s why DNS helping us to remember names only it will do the conversion of domain names to IP, because computers need IP to connect with each other.

DNS Cache Poisioning

If somehow malicious software changes the cache of your DNS with their malicious
website’s IP Address. Then all traffic will redirect to the hacker’s website.

For example you type facebook.com into the browser then the malicious website opens with same look and feel of facebook because its DNS has been changed in your cache, you will enter the email and password and boom your account has been hacked lol.

If you guys like my post please share with others.

LEAVE A REPLY

Please enter your comment!
Please enter your name here