Also called phonebook of internet is a naming system for devices such as Computer Server or Resources such as Services connected to internet. It converts human readable domain to browser/machine readable IP addresses. Although TCP/IP uses IP addresses to locate and connect to hosts (computers/servers and other devices over network), users prefer to use friendly names that can be remembered. For example, user may prefer using Facebook.com over and IP address 184.108.40.206. This naming system makes it easy to locate computers and other resources over an IP network.
Before the implementation of DNS, the use of names to locate resources on TCP/IP network was supported by a file called Hosts. It is a simple file which contains IP addresses and their names in front of them, computers then use it for name resolution. Both Hosts file and DNS use a namespace. A namespace is a grouping in which names can be used to represent an IP address, and in which rules are established that determine how names can be created and used. Hosts file needed to be updated of every computer manually which was a huge task for network administrator to distribute host file as computers grew.
DNS replaces the need to update Hosts file manually. The naming system on which DNS is based is a hierarchical and logical tree structure called domain namespace.
DNS comprises of Domain name, Domain name space and name server.
1) Domain Name: This is a string associated with an IP address For example, www.example.com
2) Domain name space: this is a domain naming hierarchy in internet naming structure. In below diagram, each sub tree represents a domain which can be divided into sub domains.
3) Name server: Name server contains DNS database, which contains various IP addresses and their corresponding names. This information is generally distributed among various name servers.
How DNS Works?
1) User opens a web browser, enters www.example.com in the address bar and presses enter.
2) Request is sent to DNS resolver, which is typically maintained by ISP.
3) DNS Resolver forwards request to DNS root name server.
4) DNS resolver forwards request again to a TLD name server. TLD name server will respond with names of name servers which are associated with www.example.com
5) DNS resolver chooses one of name servers and forward requests to it.
6) This name server looks into hosted zone for www.example.com records and get associated IP address. DNS resolver returns that IP address to web browser and also stores it for next time use.
7) The web browser now sends request for www.example.com to that IP address.
8) Web server will return request with web page for www.example.com and web browser will display the page.