The Domain Name System, or DNS, as most people know it, lets us connect to websites by using domain names instead of IP addresses.
Let’s cover the basic things you need to know about how DNS works, the terms involved, and what happens when you press Enter after typing in a website’s domain in the browser address bar.
What is DNS?
You can think of DNS as a giant phonebook of the Internet. We access websites through domain names – like techie-show.com. But our browsers (Chrome, Firefox, Safari, etc.) interact through IP addresses.
Well, DNS is the system responsible for translating those domain names we type into IP addresses so our browsers can load Internet resources and show us the content we want.
What is DNS resolution?
DNS resolution is the process of translating IP addresses to domain names.
And if you want to find out about the process behind DNS resolution, you need to learn about the different hardware components a DNS query must pass between. I must mention that the DNS lookup occurs behind the scenes, and a browser does not need any interaction from the user’s computer (apart from the initial request, obviously).
The 4 DNS servers involved in loading a requested webpage
- the DNS recursor: a server designed to receive queries from client machines through applications (like a browser, for example);
- the Root Nameserver: basically the first step in translating (or resolving) human readable host names into IP addresses;
- the TLD nameserver: this is the next step in searching for a specific IP address. If you remember from my domain article, the TLD in techie-show.com is ‘.com’;
- the Authoritative nameserver: the last stop. If this server has access to the requested record, it will return the IP address for the requested hostname back to the DNS Recursor. And now the application will start fetching content.
What is a DNS query?
Also known as a DNS request, a DNS query is a demand for information sent from a user’s computer to a DNS server. Usually, a DNS request is sent to ask for the IP address associated with a domain name – what starts happening after you typed a domain name and press Enter.
The three types of DNS queries
In your average DNS lookup process, three types of queries occur.
By combining these queries, an optimized process for DNS resolution can offer us a reduction of distance traveled. The ideal situation would be for cached record data to be available – this would allow the DNS name server to return a non-recursive query.
- Recursive query
- Iterative query
- Non-recursive query
The whole goal with caching is, as you’ve probably guessed, to temporarily store data in a location that results in an increase in performance and reliability for data requests.
DNS caching involves storing data closer to the requesting client so the DNS query can be resolved earlier without making queries down the DNS lookup chain – this reduces load times and reduces bandwidth, and CPU consumption.
DNS data can be cached in multiple locations. DNS records will be stored in a cache determined by a time-to-live (abbreviated by TTL).
DNS caching locations:
- Browser DNS caching (in Google Chrome, for example, you can go to chrome://net-internals/#dns to see the status of your browser’s DNS cache);
- Operating system level DNS caching;
An example of DNS in action – the DNS lookup
Let’s see the steps in a DNS lookup when DNS information is not cached. If some DNS information is cached, some of the steps are skipped.
- You type techie-show.com in your browser. The query travels into the Internet and is then received by a DNS recursive resolver.
- The resolver starts querying a DNS root nameserver.
- The root server responds to the resolver with the address of a TLD DNS server, in this case, ‘.com’, which stores the information for its domains.
- The resolver now makes a request to the .com TLD.
- The TLD server responds with the IP address of the domain’s nameserver, techie-show.com.
- The recursive resolver sends a query to techie-show.com’s nameserver.
- The IP address for techie-show.com is now returned to the resolver from the nameserver.
- The DNS resolver responds to your browser with the IP address of techie-show.com.
Yay! The browser is now able to make the request for the web page, since it knows the IP address of techie-show.com:
9. The browser makes an HTTP request to the IP address.
10. Techie-show.com’s server returns the webpage to be rendered in the browser.
And that would be a normal example of what happens during the DNS lookup.
I’ll end this here, as I feel this is more than enough for most users. An easy-to-understand article about how DNS works and what it is. I didn’t deep-dive into specifics, as I feel this is a long enough article, and it serves it’s purpose.
Liked it? Felt easy enough to understand? Please share it!
Tech jack of all trades. Programmer, sysadmin and a general tech enthusiast. I work with a lot of stuff, and love learning and talking about new or interesting stuff.