What is DNS? DNS Caching and Propagation explained
- 05/11/2018 6:38 PM
This article is more of an informative than a tutorial. I will explain what "DNS" is, and explain DNS Caching and DNS Propagation. I won't go too far into the complexities, and I hope you pick up something interesting from this.
DNS stands for "Domain Name System" - it was a system implemented in the early days of the internet to essentially make it more human friendly. The internet is comprised of loads of machines/servers, interlinked and each with an IP Address (ie 123.456.789.10). DNS was invented so we do not have to remember strings of numbers, and instead can use human-friendly domain names.
IP addresses are "static" and "absolute", somewhat comparible to a postal/zip code, or longitudinal/latitudinal location - something you would need to note down with precision. They are unique, random, absolute and have a single destination. Domain names however can be compared to road names or building names, they can be changed, there may be duplicates but are easily remembered by humans. DNS is what links these 2 together, and solves the issue of having to remember random strings of numbers to access a website.
Here is a step-by-step example of what is happening when your query a domain name/hostname:
â–º When you type a website address into your web browser, you trigger a virtual 'quest', for lack of a better expression, to find the IP address this domain, or hostname should lead to. This is called "domain resolution".
â–º The information your computer is trying to find is stored at the nameservers, in what is called a DNS Zone. A DNS zone is really just a list defining hostnames and their IP address counterparts among some other things such as MX/Mail records, SPF records, and some moreÂ interesting thingsÂ as the technology is constantly advancing, and we are slowly moving onto IPv6. At United Hosting we maintain 3 separate nameservers based across the UK, and USA for redundancy and performance. They are essentially massive databases clustered together, updating and synchronizing every second, ready for someone to query a domain name. They are ns1/ns2/ns3.unitedhosting.co.uk.
â–º Your computer will first consult it's local onboard cache, if you have visited the address before, it is likely you will just resolve the domain name to whatever is IP listed in your local cache.
â–º If it is not cached, your machine will query your local DNS server to obtain the IP address, these DNS servers are similarly massive databases - or a great analogy is that of a phone book, in the way they allow you to link a name/company to a phone number. DNS servers are just massive virtual phone books, which is always keeping up to date with addresses/numbers/company names.
â–º Your request will jump from DNS server to DNS server attempting to find the IP somewhere in a cache. This is a complicated, resource intensive and lengthy (from an servers perspective) process. This occurs in a fraction of a second to you and me, however it possible your request will have gone halfway across the world and back. This is where caching comes into play.
â–º There are thousands of DNS servers on the internet, and your machine will be querying a lot of them. They start to "talk" to eachother to see if any server has information on the domain you are trying to access. Assuming the site has never been queried before, your request will eventually reach one of the nameservers (the primary source of the information), and the domain will be 'resolved', the IP identified, and your computer now knows where the server is and can initiate communication.
â–º A USA visitor will most likely reach our USA based nameserver first, and likewise a European would reach our UK based nameserver first, this spreads load and increases responsiveness.
Now that the task of finding IP address is complete, it is cached (stored) on your local computer/device. This way you do not need to scour the internet for the IP address, you have it saved locally. The new discovery is also shared and cached between DNS servers - they are constantly communicating with eachother. If a DNS server is queried, it will ask multiple servers if they have the information, if they do, it will simply syncronize that data, and resolve the domain to the IP address it obtained.
There is a local software DNS cache on your computer/device, in some cases at your router/switch and at your local DNS server (usually specified by your internet service provider) as well as any other DNS servers you passed through. They will all eventually share information with eachother and have massive amounts of data cached, this process of sharing this data worldwide is called propagation.
This is a well designed and efficient system, due to heavy caching, however this can cause problems with DNS changes.
You can specify how long you would like your DNS records to be cached by changing the TTL (time to live), which is specified in seconds. Technically the cache should clear when the TTL expires (for example every hour), however if you are frequently visiting a website, your computer and local DNS server will notice this, and keep DNS cached for longer. There are also some DNS servers which will cache DNS records for longer due to lack of resources, or to reserve resources deliberately - as I mentioned earlier, it is a much longer and resource intensive process to look up DNS records, than to store a copy locally. Especially considering these servers are handling thousands of requests per second.
Clearing your computers local DNS cache is very easy:
Windows XP, 2000, Vista or 7:
1. Open the Start menu.
2. Go to Run.
* If you do not see the Run command in Vista, search for "run" in the Search bar.Â
3. In the Run text box, type: ipconfig /flushdns
4. Press Enter or Return, and your cache will be flushed.Â
5. Restart your web browser.
Mac OS X:
1. Go to Applications.
2. Go to Utilities.
3. Open the Terminal application.
4. Type: dscacheutil -flushcache
5. Press Enter or Return, and your cache will be flushed.Â
6. Restart your web browser.
Attempting to clear your local/internet service providers cache is a bit more tricky (and is usually where the problem lies) - you will need to completely restart your computer and router. If this does not fix your issue, it may be down to propagation to your physical location.
You can also try specifying custom DNS servers, such asÂ Google Public DNSÂ orÂ OpenDNSÂ which are generally accepted to be more responsive than your ISP's DNS server. If this does not solve your issue, it is most likely a propagation issue/delay.
A good way to circumvent cached DNS is to access your site through a web proxy, such asÂ http://kproxy.com. You will be tunneled through their server, giving you a fresh route to the server. Proxies are also designed to keep very up to date DNS records.
Please login to comment