What is DNS? How a DNS server works

Fredrick Sachita
3 min readJun 2, 2021

--

When was the last time you remembered your friends/family member’s phone number?? Mostly never right?? Of course you don't need to as that is the role/work of contacts in your phone books are for, you just need to save that number in your phone book and never worry about that number ever again. Well similarly DNS(Domain Name System) is a giant contact list of the internet that maps domain names with the IP(Internet Protocol) addresses.

What is DNS?

The Domain Name System (DNS) is the phonebook of the Internet. Humans access information online through domain names, like google.com or youtube.com. Web browsers interact through Internet Protocol (IP) addresses. DNS translates domain names to IP addresses so browsers can load Internet resources.

Each device connected to the Internet has a unique IP address which other machines use to find the device. DNS servers eliminate the need for humans to memorize IP addresses such as 192.168.1.1 (in IPv4), or more complex newer alphanumeric IP addresses such as 2400:cb00:2048:1::c629:d7a2 (in IPv6).

What happens when you request a website on the internet?

Let’s say you type www.youtube.com in your web browser, your query actually travels the internet and reaches your internet service provider to the DNS resolver then queries the root server with the exact domain name typed initially, in this case, www.youtube.com, then the root server basically says that I don’t know what the IP address of this domain is but I do know that I have to go (top-level domain server)which might know what the IP address is, so then the DNS resolver then goes to the .com NS(name server) top-level domain server which might know which address this is, so then the DNS resolver goes to the NS TLD(Name Server Top Level Domain) with address, in this case, youtube.com the server would know the IP address for www so then the DNS resolver goes to the Authoritative Name Server for youtube.com and brings back the IP address for it i.e 192.168.0.137 then once the IP address is found the DNS resolver sends it back to your computer (how? Through the internet obviously).

From there, it sends that request to the web server which is sitting at 192.168.0.137 and then the web server responds back with the actual web page which is displayed to the user. As we just discussed above, the resolver makes multiple queries with different nameservers and gets the IP address then sends it back to the user.

Now this doesn’t always happen, you know why?? How many times does your friend’s phone number change? Not very often right? This is the same as the DNS too, so it’s safe to cache the DNS results at multiple locations. In most cases browsers i.e Chrome, Firefox, Opera etc cache the DNS results under queries, so in our case www.youtube.com, if we again go to the web address, the browser knows or it has cached the DNS record for this address/host.

Similarly, if my browser didn’t have this address, if somebody else queried for the website URL, the ISP(internet service provider) also caches the DNS server and its records, so if it doesn’t find it in the web browser cache, it is likely to be found in the ISP cache and then from there, it will just return the IP(Internet Protocol) address right from the ISP instead of going through the entire recursive query process, it just takes it from the cache which is what happens in most cases because the DNS records don’t often change.

--

--

Fredrick Sachita
Fredrick Sachita

Written by Fredrick Sachita

Solutions Architect | Certified Gogle Cloud, Microsoft Azure,AWS

No responses yet