Tuesday, 23 August 2016

DNS Basics



Domain Name System (DNS)

                       The domain name system converts the Fully Qualified Domain Names (FQDN) to IP address. In mobile phones we save all the numbers with a contact name. Usually we search for the contact and dial the person, in fact we are dialing the corresponding number. Similarly the DNS registers the IP addresses with friendly names.
    The DNS FQDN has 3 parts. The top level domain, the second level domain and the sub domain (host name). E.g. If I want to open google.com, I will open up my browser and type http://www.google.com in the address field. First my machine will look for the DNS server to get the IP address for www.google.com. The www.google.com is called as the FQDN. The .com is the Top Level Domain and google is the second level domain. There are so many top level domains like .edu, .gov, .info etc. Under each top level domain there are millions of secondary domains. www is the host name represents the actual web server. You can give any name as the host name. www is just the conventional name used for web servers. The total length of the FQDN cannot be more than 256 characters.
   So in order to get the IP address my machine will contact the local DNS server. It can be a server setup in your office or for most home users the ISP’s DNS server. If you open up a command prompt and type ipconfig /all, you will be able to see the primary DNS server IP address.
           All DNS servers are setup with root hints. Root hints are reference to a bunch of DNS servers having the details of all Top level domains. There are 13 root servers in the entire globe in different locations.  The “.” represents the root server. So in order to resolve the IP my DNS server will contact one of the closest root server. The root server will return me the IP address for the .com server. Again my DNS server will contact .com server to get the IP address of www.google.com and it will return the IP address of google.com authoritative DNS server. Again my DNS server will contact google.com authoritative DNS to get the IP address of www (the actual web server).Once my DNS get the IP, it will return to me with that and I can establish communication with  www.google.com


      Once it get the required IP the local DNS as well the client caches this information for a specific period of time as configured. So next time if any client requires to resolve the same host name, it can serve straight away without the above procedures. 

Domain Name Registration

  In order to setup our domain name with the DNS, we need to register our domain name with a known registrar in the Internet. The name space of the internet is controlled by ICANN, a non profit organization. ICANN is collecting a maintenance fee from each registrar.There are so many registrars like godaddy,register.com etc. Most registrars offer DNS hosting as an optional free service. The registration service is useless without DNS services for the domain.

DNS record types

SOA record: Indicating the IP address of DNS servers that are authoritative for the domain.
A Record: It is the basic type of DNS record which maps a domain or sub domain to an IP address.
CNAME record: They are also known as alias which used to point one host name to another host name.
MX record: It is the mail exchanger record, which is used to locate the mail server.
    There are so many different DNS record types which we will cover later when we will discuss later in the DNS setup section.

                              Prior to DNS a text file called HOSTS was used for name lookup. It simply contains the friendly name and their corresponding IP addresses. All Linux, Mac and Windows based OS having this record. It is having precedence over DNS.

Dynamic DNS
      Usually a home or small office based router gets a dynamic public IP from the ISP DHCP pool. So if you want to access a web server or IP camera in such network, you can’t register a fixed IP with the DNS registrar, as the IP changes dynamically. In such situations you can rely on Dynamic DNS providers like dyndns.org to register your domain with them. Usually they have a client side software which runs either in your computer or router and that updates dynDNS server regarding the changes in the IP and the same updated automatically in their system.

DNS Troubleshooting Tools
           DNS is very important for network applications, as they required name resolution. In this section we will discuss how can we check DNS failures? Most of us seen that if we open a webpage, and instead of loading the page the browser ask you to check the DNS settings. At first you make sure have valid IP configurations and open up command prompt and try to ping the website you want to open. See the picture below, when I type ping google.com and hit enter key, The first line itself showing the name resolution happened.


         Let us check my IP configuration. 

You can see my DNS server is 192.168.1.1, same as my DHCP server. I am connected with my broadband router and broadband router proxies the DNS service to the ISP DNS server. I am just going to change the DNS settings of my machine with an invalid DNS server address to show what we will get as the ping result.
    As you can see it failed to resolve the hostname.

   NSLOOKUP is one of the popular command line tool used to check the DNS issues. You can use nslookup to change the DNS server to different IPs using the server command and can check the differences. As you can see in below picture my DNS server was 192.168.1.1 and it is just a proxy to my ISP. I changed it to the most popular and powerful google DNS server to see the differences in the query results.

1 comment: