Flush DNS Cache: All you Need to Know

Flush DNS Cache All you Need to Know
Last updated Sep 13, 2021

All devices connected to the internet use IP addresses to interact with one another and exchange information. Whenever we type in a website name in a search bar, the browser will first convert that domain name into an IP address, and then extract the web page. 

It achieves this conversion through a DNS (Domain Name System).

A DNS is like an address book, but for the internet. It keeps a record of all the domain names corresponding to their IP addresses. So when you type in a domain name in your web browser, the browser first contacts the DNS for the IP address pertaining to the domain name requested, and then fetches the web page you’re looking for.

Table of Content

  1. What is DNS Cache?
  2. Why flush DNS Cache?
  3. How to Flush DNS Cache
  4. Summary

What is DNS Cache?

A DNS cache is a temporary storage of all the previous websites a user has searched for or visited. 

Each time a new request is made to a web browser, the browser has to contact the DNS recursor, who then sends a request to the root server, who in turn has to contact the TLD nameserver to access information. 

Since a lot of steps are involved, it’s feasible to store the domain name information of all websites the user visited in the past so that the waiting time for each recurring request can be reduced.

This is called DNS cache. Your OS stores all domain names corresponding to their IP addresses so that it can retrieve information quickly and efficiently, the next time you type in the same request. 

Why Flush DNS Cache?

1.Security

If internet hackers get access to your DNS cache, they can manipulate the data to get sensitive information. They can change the entries in such a way that the next time you visit a website, you could get redirected to another site that is a mock-up of the original one. 

Imagine entering personal information like passwords and bank details on such a website!

To protect yourself from such DNS poisoning or DNS spoofing, it’s important that you clear DNS cache periodically. 

2. Bad connections

Sometimes, it’s possible for your DNS cache to have stored wrong IP addresses. It could be because a website has changed its IP address for some reason, or because of some virus or malware in your computer. 

Nevertheless, these bad IP responses will direct you to the wrong website each time you enter a request for that particular site. 

Flushing your DNS cache will discard all the wrong information, and your browser will fetch the correct entry. 

3.Search behavior tracking

A DNS record will make will contain your entire browser history, including your most visited websites, or the sites you frequent daily. This can make your online behavior very evident. 

Again, this information could fall in the wrong hands and your privacy might be exposed.

Interesting read: Redirect HTTP to HTTPS in 4 Simple Steps

How to Flush DNS Cache

The method of flushing DNS cache varies on different operating systems. We’re going to the methods on Windows, Linux, Mac, and Ubuntu.

I. Windows

On Windows, you have to run a DNS flush via a command prompt. 

  1. Click on the windows home button and search for command line tool by typing ‘cmd’. 
  2. Enter the following command: 
ipconfig /flushdns

Windows will then flush DNS cache and you will get a message confirming the same. This method is valid for Windows 7, 8 and 10.

II. Linux

Linux systems don’t have default or integrated DNS caching systems. To store DNS cache locally, you have to use applications like nscd (name service caching daemon), dns-clean, dnsmasq,or pdnsd. 

  1. Press Ctrl+Alt+T to open your DNS system’s window. 
  2. Then run a command to flush DNS cache

For pdnsd, the command is:

sudo pdnsd-ctl empty-cache

For dns-clean, pdnsd or dnsmaq, you have to completely restart the service. The command for that is:

1. sudo /etc/init.d/dnsmasq restart
2. sudo /etc/init.d/nscd restart
1.sudo /etc/init.d/dns-clean restart

III. Mac OS

On Mac, the command to flush DNS depends on which version you’re using. 

  1. Press the F4 key, then search for ‘terminal’ to open the terminal window. 
  2. Enter commands, as mentioned below, depending on the version you’re using.

If you’re using macOS 10.12.0 (Sierra) then enter the following command

sudo killall -HUP mDNSResponder

If you’re using OS X 10.10.4 (Yosemite) and 10.11.0 (El Capitan) then: 

1. sudo dscacheutil -flushcache;
2. sudo killall -HUP mDNSResponder

If you’re using OS X 10.10.1 to 10.10.3 (Yosemite):

1. sudo discoveryutil mdnsflushcache
2. sudo discoveryutil udnsflushcaches

If it’s OS X 10.9.0 (Mavericks) then:

1. sudo dscacheutil -flushcache;
2. sudo killall -HUP mDNSResponder

For Mac OS X Leopard, the command is:

sudo lookupd -flushcache

IV. Chrome Browser

Since your browser stores DNS cache too, it’s important to clear that as well to get rid of any wrong IPs or for security.

  1. In Chrome’s search bar, type chrome://net-internals/#dns .
  2. Chrome displays the option to clear host cache. Click on it.
  3. Then on the side menu, click on ‘sockets’.
  4. Click on ‘close idle sockets’ and ‘flush sockets pool’.

Summary

Flushing DNS cache can protect you from cybercriminals and can resolve any technical difficulties you might be facing while loading websites. To run DNS caching, you need to use different commands, depending on the operating system (Windows, Mac, Linux) you’re using.

If you have any comments or suggestions, do mention below!

  •  
  •  
  •  
  •  
  •  

1 Comment

  1. Latosha Mcrorie

    You write well, subscribed to the feed

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *