en
  English
Phone :  +370 (5) 204-1903
Email: sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How to Flush DNS

Before we get to the tutorial on How to Flush DNS on your system, we will first cover the basics. If you are here specifically for the how-to part, go ahead and skip to the tutorial!

Today everyone is relying on the internet for even the smallest bit of information. Thus, many websites get a lot of traffic every second, and users tend to leave their traces online. Many websites and applications use cookies or JavaScript applications to store users' or visitors' details and trace their behaviour. Such information may help both websites and visitors to access the link quickly during a second attempt. 

The data stored as a cache helps in optimizing the website without compromising visitor details. Many people habitually delete their cache and browsing history to ensure that their details are not stored for any website to protect their privacy. They are also known as web trackers. 

While websites and browsers save data, the operating system also tends to store surfing behaviour. They are stored in the automatically generated DNS cache which contains temporary details about all visited sites online.

This article will go through what is a DNS, how to manage and how to flush DNS cache. 

What is a DNS Cache?

DNS servers help in converting the domain name into the numeric address processed by a computer system. The browser contacts the name server every time a call is made, leading to increased load time and DNS server overload. You might have seen the error like "DNS Server Not Responding", which is the consequence of many requests being made.

This is why the operating systems tend to store their cache; which are evidently known as DNS cache. It holds the data which will be valid for a particular time. Until the cache is valid, all the requests will be made directly from the saved DNS cache rather than visiting the DNS server repeatedly.

What information is stored inside the DNS Cache?

The entries created and contained within the DNS cache are called resource records (RR), stored in the ASCII code to ensure data security. Also, it is quickly processed by your machine where it is stored.

Below are the components of the data stored:

  • Resource Data (RD) is used to describe the record, like its address or the hostname. It helps in identifying what type of resource you are connecting to.
  • Record Type- this component will specify the type of record created. For example- the 'A' IPv4 address or the 'AAAA' IPv6 address. This information helps you understand what kind of connection is being used by your network to the outside.
  • Record Name- this is the optional component; it may be created or not. If this data is created, it will specify the object's domain name for which the entry was created.
  • Time to Live- this component is optional and used to specify the resource record's validity in seconds.
  • Class- this component is optional, which is used to specify the category to which the record belongs.
  • Resource data length- this component is also optional, which specifies the size of the resource data.

If you want to check for yourself, here's how to see DNS cache in Windows 10:

Open command prompt > Type "ipconfig/displaydns" > press Enter

Here's how to view DNS cache on Mac:

Part 1: Open the Console app > select your device from left sidebar > Type any:mdnsresponder in the search bar

Part 2: Open command line > enter the following sudo killall -INFO mDNSResponder 

Part 3: Check Console app for the list of cached DNS records

If you are using a Linux system, here's how to use the cached DNS records:

Open terminal > Enter service nscd status or sudo service nscd status

Note that you will need to have NSCD daemon!

Why Should You Flush DNS Entries Regularly?

The DNS entries are created automatically by the operating system to ease their process to make server calls. But this DNS cache entry is not going to be deleted automatically (even though it gets generated automatically) you have to do it manually. It is important and beneficial that you clear up the DNS cache periodically or regularly. DNS cache clearance is necessary due to the following three main reasons:

  • Protect Your Search Behavior - A user's surfing behaviour is usually tracked by cookies, JavaScript applications, and other possible ways. DNS cache, however, tends to increase the security vulnerability more than any other tracking method. This is because the DNS cache contains all the information and addresses the user has visited within their valid time (TTL). The information has a higher chance of reducing the server load times and reveal your browsing activities. 
  • Increase the Risk for Cybercrime - DNS entries may be useful to keep track of your activity, but it might be a threat if these entries fall into the wrong hands. If an attacker gains access, they can manipulate the entries and redirect them to different sites, leading to DNS-poisoning or DNS-spoofing. Most attackers use this to gain access to gain sensitive log-in details like your online banking details.
  • Solving Technical Issues - Are you continually experiencing any technical issue while accessing any website on your system? This may be due to the DNS cache's outdated entries allowing you to open the website's wrong link. It is essential to clear the DNS entry and revisit the site so the new entries will be created in the cache and can successfully access it.

If the entries are not deleted manually, the entries will remain in the cache until their TTL expires. Sometimes using a corrupted cache can lead to security vulnerabilities, so it is strictly recommended to flush your DNS entry whenever you feel.

How can you clear or flush DNS entries for different operating systems?

There is no golden rule saying when and why you should be clearing your DNS cache, but it is considered an excellent digital practice, especially if you are working on crucial projects. If you feel that something is wrong with your websites redirection, it is high time to check the DNS caches. You should follow the exact instructions for clearing cache concerning the operating system you use.

If you have a Windows VPS, the command to flush DNS will be precisely the same as mentioned here. 

** Note: ADMIN rights are required to delete DNS cache from any operating system.

Clear DNS cache in Windows XP, 2000, or Vista

If you are using Windows XP, 2000, or Vista, first, you should clear the DNS entry using the command prompt command. 

  • Click on the Start button.
  • Type cmd in the search bar.
  • The command prompt black screen will open.
  • You can now enter the below command to clear the DNS cache.

Ipconfig /flushdns

Once you press the enter key, the entries will be cleared, and you will get a success message

How to Flush DNS in Windows 7 

If you are using Windows 7, then you can clear the DNS entry via command prompt command. 

  • Click on the start button.
  • Type cmd in the search bar.
  • The command prompt screen will open as below.
  • Now you can enter the below command to clear the DNS cache.

Ipconfig /flushdns

Once you press the enter key, the entries will be cleared, and you will get a success message as below.

Flush DNS in Windows 8

If you are using Windows 8, you can run commands via the command prompt tool to clear the DNS entry. 

  • Click on the start menu.
  • Search for the cmd from the search bar.
  • A black screen of the command prompt will open.
  • Run the below command.

Ipconfig /flushdns

On pressing the enter key, you will get the below message as you get for Windows 7.

How to Flush DNS in Windows 10

If you are using Windows 10 operating system, there will also be the same process that we followed for Windows 7 and 8. 

  • You can search for the cmd from the search function.
  • A black screen for the command prompt will appear where you can run the command.
  • Clear the DNS cache via the below command.

Ipconfig /flushdns

On pressing the enter key, you will get the below message as you get for Windows 7.

Clear DNS cache in Linux Operating Systems

By default, the Linux operating system does not have the facility of DNS cache entries. They come with a function that stores the DNS information locally using some applications like nscd (name service caching daemon). 

If you are using a Linux VPS, the command to flush DNS will be exactly the same as mentioned here. 

If you are using caching services, you can control it from the terminal to clear the cache. Similar services are:

  •  pdnsd
  • DNS-clean
  • dnsmasq

Below are the different commands for different services. Well, you will need admin rights to clear the cache on Linux distributions.

  • For pdnsd, run the below command.

sudo pdnsd-ctl empty-cache

  • To clear the DNS cache using dnsmasq command

sudo /etc/init.d/dnsmasq restart

  • To clear the DNS cache using ncsd command

sudo /etc/init.d/nscd restart

  • To clear the DNS cache using dns-clean command

sudo /etc/init.d/dns-clean restart

How to flush DNS in macOS

macOS works the same as Windows for automatically collecting the DNS information. Thus it also needs to be cleared up manually and regularly. But on macOS, the resetting the cache may vary depending on the macOS versions. You should set the DNS register to zero from the terminal. The procedure to do this highly depends on the version of your Mac system. Follow the steps below to access the terminal.

Go to Applications -> Utilities -> click Terminal. 

Before running the command, you must have admin privileges.

macOS 10.12.0 (Sierra) version

sudo killall -HUP mDNSResponder

OS X 10.10.4 (Yosemite) and 10.11.0 (El Capitan) version run the below command

sudo dscacheutil -flushcache;

sudo killall -HUP mDNSResponder

OS X 10.10.1 to 10.10.3 (Yosemite) version run the below command

sudo discoveryutil mdnsflushcache

sudo discoveryutil udnsflushcaches

OS X 10.9.0 (Mavericks) version runs the below command.

sudo dscacheutil -flushcache;

sudo killall -HUP mDNSResponder

Conclusion 

DNS cache is vital to lower your server load for many requests, but it is also essential to maintain security by deleting DNS cache regularly. This is one of the little technical details that you might miss if you are a beginner, but making this a habit will help you in the long run. It will save you from vulnerabilities and protect your system from unexpected attacks. You can also make this a task or a batch job that will delete your DNS entries from time to time and save your manual effort.

We hope this article helped, and if it did, don't forget to share it with your peers! You can always let us know your thoughts in the comments below!

author img

Nisal N

Computers has always fascinated me since I was a kid and here we are. I love travelling for 2 reasons: the first one to see a new part of the world and second (the most important one) to experience the rich culture hidden among the country and people. I'm pretty good at cooking but very poor when it comes to baking.

Leave A Comment