Domain Name System (DNS) is a system of converting domain names to designated IP address. As it is difficult for us humans to remember all the IP address of websites we want to visit so DNS helps us to convert the name of the website say google.com to the IP address.
In order to understand the process behind the DNS resolution, it’s important to learn about the different hardware components a DNS query must pass between. For the web browser, the DNS lookup occurs “ behind the scenes” and requires no interaction from the user’s computer apart from the initial request.
There are 4 DNS servers involved in loading a webpage:
- DNS recursor – The recursor can be thought of as a librarian who is asked to go find a particular book somewhere in a library. The DNS recursor is a server designed to receive queries from client machines through applications such as web browsers. Typically the recursor is then responsible for making additional requests in order to satisfy the client’s DNS query.
- Root nameserver – The root server is the first step in translating (resolving) human readable host names into IP addresses. It can be thought of like an index in a library that points to different racks of books – typically it serves as a reference to other more specific locations.
- TLD nameserver – The top level domain server (TLD) can be thought of as a specific rack of books in a library. This nameserver is the next step in the search for a specific IP address, and it hosts the last portion of a hostname (In example.com, the TLD server is “com”).
- Authoritative nameserver – This final nameserver can be thought of as a dictionary on a rack of books, in which a specific name can be translated into its definition. The authoritative nameserver is the last stop in the nameserver query. If the authoritative name server has access to the requested record, it will return the IP address for the requested hostname back to the DNS Recursor (the librarian) that made the initial request.
When you type an IP address in the address bar your system first checks the local cache for the associated IP address. If the IP address is not in the local cache the system then forwards this DNS request to DNS recursor which looks for the root nameserver that might hold the information.
If the root nameserver also doesn’t know whats the IP address of the requested query then it directs the DNS recursor to TLD nameserver. TLD namerserver updates the cache of the DNS recursor and points to the the authoritative nameserver which holds the associated IP address for the DNS query.
Most of the querying is done by the DNS recusor and it performs this routine only on the first time request after which it creates an IP address entry for that DNS query in its cache to avoid going through the process every time.
DNS can use both transmission protocols TCP and UDP. But general usage is over UDP protocol because of its simplicity and speed.
One of the used DNS port is TCP Port 53. TCP provides stability over DNS resolutions process. With TCP 53 there will be no data loss over network transmission which makes DNS transaction more stable. But this will create some overhead for the server and client because of the TCP behavior.
Most known and popular usage protocol of DNS is UDP 53. Most DNS servers uses UDP 53 port which provides simplicity and less resource usage.