What is a DNS Cache?


A Domain Name System, or DNS for short, is a group of data lookups that help translate human-readable URLs/Domain Names into machine-understandable IP addresses. It is usually referred to as the phone book for the internet as it helps users pull up websites using the URL which is then translated into an IP address that helps the web browser locate the web resources and display them accordingly.

Without DNS, along with search engines, navigating through the World Wide Web wouldn’t be as easy as it is today. We would have to compile a list of IP addresses of all the desired websites and enter them accurately every time looking to visit them.

If you are still unclear on the concept, let’s take a deep dive into the topic.

How does DNS work?

DNS, or the Domain Name System, is a system that translates domain names, such as www.example.com, into IP addresses, such as 192.0.2.1. When a user types in a domain name into their web browser, their browser first checks within their DNS cache and if its not there will send it over a server ISP to resolve the name to an IP address.

The DNS server then looks in its database of domain name mappings, called the DNS zone, for the corresponding IP address. If the server does not have the mapping in its zone, it will forward the request to other DNS servers until the correct IP address is found. Once the correct IP address is located, the DNS server sends it back to the browser, allowing the user to connect to the website associated with the domain name.

What is a DNS Cache?

A DNS cache, colloquially also known as the resolver cache, is a temporary storage system for DNS query results. When a DNS server receives a query for a domain name, it will first check its cache to see if it has a recent, or “cached,” response for that query. If it does, it can return that cached response to the user without having to do a new query to other DNS servers. This can speed up the resolution process and reduce the load on the DNS system as a whole.

The purpose of the cache is to reduce the time needed to resolve domain names by storing the recent resolution, this way it doesn’t need to be resolved again. The cache will expire after a certain amount of time (TTL: Time To Live) and will be deleted. When the cache expires or if it doesn’t find a match for the query it will forward the query to the appropriate DNS server for resolution.

How to check the entries in your DNS cache?

Generally, all operating systems maintain a local DNS cache to reduce the turnaround time for all queries. If you want to check the contents of your local DNS cache on a Windows Machine, you can check it using the following in your command prompt.

$ipconfig  /displaydns

Here you can see that all the required information is neatly stored in sections with information against all of the queried URLs.  

Similarly, if you want to pull up the contents of your DNS cache on Ubuntu, you’ll have to utilize the “system-resolved” command. There is no single command you can utilize to pull up the contents. You need to send a kill signal to the systemd service, using the following:

$sudo kill all -USR2 systemd-resolved

Now you can use the following command to pull up the contents of your DNS cache:

$sudo journalctl -u system-resolved > ~/dns-cache.txt

This will create a text file with the contents of your DNS cache. You can use the following to open up the text file in your terminal:

$less ~/dns-cache.txt

Conclusion

Though can directly enter an IP address into your web browser, remembering the URL that is specially designed to be easier for humans is far easier. Doing it, either way can help you open up the website. That said, if you’ve been facing issues with accessing websites knowing how the web browser and the internet work with the websites can help troubleshoot the issues much easier.

If you are having an issue accessing your desired website, you can bypass the error by directly entering the IP address into your web browser. I hope you were able to easily follow through with the guide and understand exactly what is a domain name system and how does it work. If you still have any queries, concerns or requests for follow-up guides, you can reach out to us through the comments section and we’ll be glad to help.

Print Friendly, PDF & Email