We’re conditioned to take the Domain Name System for granted. It operates unseen in the background, doing its thing without much fuss or maintenance. Despite its low profile, the DNS is the critical backbone of modern network communications. Virtually everything that we undertake on the internet, such as opening a website, browsing through webpages, checking email or accessing web based services, is underpinned by the Domain Name System.
What is the DNS?
DNS is the magic that makes the Internet logical and navigable for its human users.
The DNS is a distributed global database that translates semantic or human-readable hostnames such as www.webnames.ca into machine readable IPv4 or IPv6 addresses such as 184.108.40.206. Without DNS, we would need to use IP addresses to reach websites...and while that might work fine for a machine, navigating the internet by way of an infinite maze of numbers would simply be untenable for most humans. In addition to mapping domain names to websites, the DNS also provides mappings to things like mail servers, SIP servers, redirects, digital signatures and more. DNS also makes it easier to move, modify and change internet services because the front-facing domain name remains consistent even when the IP address of a service changes in the background.
How does DNS work?
As explained above, each time a domain name is typed in a browser it is automatically passed on to a DNS server, which translates the name into its corresponding IP address - for example, the domain name Webnames.ca is translated to 220.127.116.11. In order for this to happen seamlessly, a number of steps or exchanges must take place.
Step 1: Send the Request & Check the Local DNS Cache
The process begins when you ask your computer to resolve a hostname, for example visiting www.google.ca or www.webnames.ca. Your computer will first query its local DNS cache to see if it can retrieve the answer from there, and if it does not find it there it will perform a DNS query to find out.
Step 2: Query the Recursive Nameservers
If the information is not stored locally on your computer, the next query goes to your ISP or mobile carrier recursive DNS servers. These specialized computers perform the legwork of a DNS query on your behalf. Recursive servers have their own caches and therefor know what other DNS servers it needs to ask to get the answer to your query – namely "hat is the ISP address for Webnames.ca?
Step 3: Over to the Root Nameservers Next
When the recursive servers can’t answer the query, they pass along the request to the root nameservers. Root nameservers run all over the world and each one where information about TLDs (top level domains) can be found...they are like intermediaries, they don't know the answer themselves, but they know who (or in this case, what) to ask to get it!
Step 4: Knock Knock on the Door of the TLD Nameservers
TLD nameservers read queries from Right-to-Left, which means that they start with the domain extension (e.g., .CA, .COM, etc.). Each TLD has its own nameservers that acts like a switchboard operator (remember those?), directing our query to the next set of servers which have the information we need – the DNS servers!
Step 5: Ask the Authorities...Authoritative Nameserver, that is!
The recursive resolver now sends the query over to the specific nameserver (aka DNS server) that is responsible for the domain we want to reach. This nameserver knows all of the information about the domain name, including its A-record, which points to the IP address and location of the domain's website on the World Wide Web.
Step 6: Fetch the (A) Record
With the A-record in its possession, the recursive server now stores the information in its local cache – now if anyone else wants to go to www.webnames.ca, the recursive serve can skip the lookup process until such time that the corresponding TTL (time-to-live) packet expires.
Step 7: Show me the Website!
The recursive server now completes its job as a go-between, returning the A-record information back to your browser. Your browser then sends a request to the website to receive it's content, using the IP information it took from the A-record.
Thankfully the above process occurs approximately one-hundred thousand times faster than the time it took for you to read this explanation!