Everything You Need To Know About DNS

DNS. Three letters that can make or break your website. A fault with DNS and your website can go down for 24 to 48 hours. What is DNS? From where does this 48 hour delay come from in the age of super fast Internet and high-speed technology? Why hasn’t the ever evolving technology replaced the age-old DNS and the frightening 48 hours delay? This discussion will shed some light on most of the queries about DNS. I hope that you will see DNS from a completely different perspective after this writeup.

What is DNS?That is the customary question that we got to answer when we are discussing something as vast as DNS. Basically, DNS (Domain Name System) is responsible for translating human friendly website URLs like www.1stwebdesigner.com to computer readable IP addresses like 148.68.30.27 (just an example). You know, our mind cannot remember combination of such digits so we devised a system which helps convert these IP addresses to English names and vice versa.
Please understand that DNS isn’t a localized system where all the IP addresses corresponding to every website present on this planet is stored. If that was the case then an unimaginable amount of care would be required to keep such a huge database working. Also, having a localized DNS would be against the distributed character of the Internet.
Rather, DNS is a distributed service which is actually a collective group of name servers (which we call as “nameserver” in Internet lingo). These nameservers constantly refer to each other in order to stay updated with the changes that are rolled out every now and then. The process sounds simple but it is quite complex.
So, every website has a nameserver?Well, technically speaking, yes! Though it’s a different case that one nameserver will be used for multiple websites. Otherwise, we would end up having 100 million nameservers for 100 million domains – which makes no sense. Like, I host a domain of mine on DreamHost.com. So, they give me nameservers like ns1.dreamhost.com, ns2.dreamhost.com and ns3.dreamhost.com. Now, DreamHost is giving these nameservers to almost every client that they have. So, these three nameservers basically have almost all the IP address to URL details of every DreamHost client.
A basic flow of request on the InternetWhen you type Google.com in your browser then a lot of stuff happens behind the scenes before you get to see the Google homepage. The image below tries to explain the flow of request.

Let me try to make it bit more clearer:
When you visit a website URL via your browser then Windows will look for the corresponding IP address stored in the nameservers of your ISP.If the IP address is found then the request is directly sent to that IP address henceforth reducing the execution time.If the IP address is not found locally then the request is sent to the cloud of Internet and your browser waits for the virtual world to do its job.Every website has a nameserver associated with itself. Henceforth, that particular nameserver receives that request and sends it to the respective IP address.If that nameserver does not have the IP address details then it communicates with other nameservers and they with others. The request flows in the Internet till correct IP details are attained.Once the IP address is known then the request is sent to the particular IP address and data is served.What is “48 hours delay”?Usually, when you are about to change the nameservers for your domain or when you are hosting a fresh domain then your hosting company will tell you that it might take up to 48 hours for the information to be updated. Technically speaking, they are correct. It might take up to 48 hours for all nameservers on this planet to connect with every other nameserver and keep themselves in sync. You see, it’s a huge virtual world out there. But, my personal experience says that it usually takes less than 24 hours for the global update to complete. Still, you should consider the 48 hour delay in your time plan before you make any changes.
The below image via Wikipedia will give you an idea of hierarchical DNS, organized into zones, each served by a nameserver.


How and when does caching occur?Nice question. You got the information for Google.com request that you had sent some time back. Now, that information is saved in the local ISP’s nameservers so that next time your request isn’t sent to third-party nameservers. But, after a stipulated time period these nameservers contact other nameservers so that their information isn’t outdated. This is where the term TTL comes into play.
What is TTL?TTL (or Time To Live) is the time period that comes in along with the IP address info. This time period information is sent by the third-party nameserver along with the IP address. The value is usually in seconds and it is more like a suggestion from the third-party nameserver that you can stay away from me for X seconds and still stay updated. Come back after X seconds and I will pass on the latest information.
Usually the TTL value is 12 hours or 24 hours. This can be set to a custom number as and when required to reduce traffic.
Other types of DNS lookupsOnce DNS started to serve the IP address lookup (as discussed above), then it was time to expand. DNS was later on used for other type of lookups, two of which we will discuss below:
A Record – A Record lookup is something that we have already discussed. The IP address lookup is actually the A Record lookup for DNS.MX Record – MX (which is acronym for “mail exchanger”) is used for email address lookups. Usually when a tool tries to send an email to mail box related to your domain then it will look for MX record of your domain. This MX record will have another domain (something like mail.yourdomain.com) as its value. Now the A Record for this MX record will be checked to get the target IP address.CNAME Record – CNAME (stands for Canonical Name Record) is actually an alias for another domain name. This comes in handy when you want to use your own domain and data from another website. Like, during the ancient Internet Age (when blogspot.com was luxury), blogspot.com had a feature (they still have it) where you can use your own domain (yourdomain.com) instead of using the bogspot’s sub-domain for your blogspot hosted blog. In this case all that Google would do was ask you to change the CNAME of yourdomain.com to your blogspot’s sub-domain and the job is done. Whenever one would visit yourdomain.com then the data from your blogspot’s sub-domain will be delivered although the sub-domain won’t be visible in address bar.Other usage of DNSOther then the three lookups that I discussed above, DNS can be used for many other functions like:
As I discussed before, domain names and nameservers do not have a one-to-one matching. This gives the hosting companies the chance for shared hosting and save a lot on money invested. Here, multiple domains can result into one IP address. This means one machine can host many websites. Additionally, one domain can point to multiple IP addresses. This helps in redundancy and high availability.The DNS system can be used to save and share IP addresses of blacklisted email hosts. Such databases are available for free in order to fight spam.These days software makers save the version of a software in the DNS database. This way the client machine connects to find out the latest version of the software available. It connects to the software maker’s server only if a new version is available. This helps in reducing the requests that client machines get.

No comments:

Post a Comment