How DNS works

24 Jul

Everybody uses DNS yet not everybody knows exactly how it works. DNS, short for Domain Name System is a protocol where a website name is translated to it’s machine address, also know as the IP Addresses.

Computers  communicate with each other by IP addresses which can be treated as a telephone number for each machine on the Internet. The DNS main job is to turn the domain name like www.netumo.com to an IP address like 191.238.8.26.

This IP address is used to locate one of the Netumo servers on the Internet quickly and directly. With the use of DNS you don’t have to keep an address book with all domain names and the equivalent IP Addresses.

Resolution works as follows:

  1. You type in the browser www.netumo.com
  2. The browser relays this information to the Operating System (OS) which in turn would try to resolve it. If it’s found in the OS DNS cache then it’s immediately returned. Otherwise it goes off to the Internet provider DNS server.
  3. If the Internet Provider DNS server does not know the query it can go to other DNS server recursively.
  4. If these don’t have the answer then they query the root nameservers. A nameserver is a server that answers questions about domain names.
  5. The root nameservers will read the query from right to left. For www.netumo.com they start off with .com. In such a case the query will be directed to the Top Level Domain (TLD) nameservers for .com. There are TLD for each domain like .com, .org, .us, .watch, .tv etc.
  6. The TLD nameservers then review the next part of the request netumo.com and direct to the responsible authoritative nameserver.
  7. The Authoritative nameserver would know all the information on the domain and would return the A record (which stores the IP Address) for www.netumo.com
  8. Once all this is done then the OS would receive the answer and return it to the browser. The browser can then use the IP Address to connect directly to the Netumo server.

DNS servers do cache the information so that if multiple queries come for the same site they can quickly relay the information. This is why all records have a Time to Live (TTL) such that they expire after some time and would have to be fetched again. This makes the system possible to cache data for some time yet updates are still possible if for example a server is moved from one location to another.

Well is this too complicated? Have a look at this short video which explains all of the above.