Thursday 9 August 2012

WHAT IS DNS & HOW A DOMAIN LOADS

DNS: 

I will explain here the meaning of DNS in simple words.

­Human-readable names like  "maninmanoj.com" are easy for people to remember, but they don't do machines any good. All the machines use names called IP Address to refer to one another.  That is they communicate with each other with the help of numbers called IP address.

For example, the machine that humans refer to as "maninmanoj.com" has the IP address 216.239.32.21. Every time you use a domain name, you use the Internet's domain name servers (DNS) to translate the human-readable domain name into the machine-readable IP address. 

Now, the question is how a domain loads? 

We will take here the example of  "abc.com". When we type "abc.com" in the browser(assume abc.com is loading for the first time) . The query will first check the browser cache. If the information is present in the browser cache the website loads from there.

Here, in our case since abc.com is loading for the first time,so there is no question of cache comes into picture.

Now, the query will check a file in Linux machine "/etc/nsswitch.conf"(please check this file in your Linux machine).There will be two entries,  dns and files in "nsswitch.conf". Here files refer to /etc/hosts and dns refers to /etc/resolv.conf.

First, the query check /etc/hosts file for any entry, if it find the IP address there then the query will not go to the outsideworld. Else, it check the file /etc/resolv.conf.

In the resolv.conf the entry will be the IP address of the nameservers of  ISP( Internet Service Provider). Normally, ISP has the cacheing nameservers. If the IP address is available in that cacheing nameservers then, the query will return that IP address to the browser. Else, the query is forwarded to the next cacheing nameserver and so on.

Snce our domain is loading for the first time none of the cacheing nameservers will have the entry. So, the query is forwarded to root nameservers. The root nameserver will tell the query to contact "com"  nameservers and "com" nameserver will tell the query to contact the nameserver of  "abc.com". 

Ultimately, the query will find the IP address( A record) of the domain "abc.com" from the zone file of the domain and return it to the browser.

The browser will then contact the webserver with that IP address and loads the website.


No comments:

Post a Comment

Note: only a member of this blog may post a comment.