Monday, July 27, 2009

DNS: How it Works

We know every thing which we access in the internet has a public ip address. That is suppose when you want to access a web site(www.gmail.com), you type it on your address bar of your browser and you find the pages. But host name is not used in the internet. Because host name may be variable of size, so storage is difficult. For this reason, we use ip based system. In this system, every host in the global internet has an ip(public or private) address. So some mechanism is needed to translate host name to it's corresponding ip address. DNS does the work.

DNS-Domain Name Service is a client-server based software approach to solve the host name to ip address translation. But DNS does more than ip translating, which I will describe in another lesson.

In the early time of the internet every computer stores a host file on it's hard disk which contains simply the mapping of host name to ip address. But when huge information have to store this system failed. So a centralized process is needed to solve the problem.

There are some (around 13) root DNS server around the world. Every root DNS server contains info in a hierarchical manner.

-> At the top level the root
-> The top level domain(.com,.org,.bd,.in etc)
-> Authoritative domain (gmail)

By this manner info is stored.

So the question is how the DNS is resolved?

Step 1: When you type the hostname(www.google.com) on your browser and hits ENTER then a DNS request message is send on the local DNS server.

Step 2: If the local DNS server has the ip address of the hostname, it will forward the ip address as a DNS response message to you. So it acts like a cash between your machine and real DNS server.

Step 3: If the local DNS server has no record regarding on the host name what you specified it calls one of the root DNS server to solve it. So the local DNS sever knows the (ip) address of the root DNS server.

Step 4: The root DNS server looks the request and sees the it has the top level domain .com. The root DNS server knows the address the .com.

Step 5: The .com finds the authoritative domain (google) and now actually we know the ip address of www.google.com.

Step 6: The ip address is backpass and at a time it will come to the local DNS server. The local DNS server stores a copy of it and forwards it to you.

Step 7: Now you see the web page www.google.com. All the works are done in fraction of seconds.

Look at the picture for better understanding

0 comments: