Introduction
Caching is a common method used by computer operating systems to cache the outcomes of DNS lookups. In most cases, this is not a concern and typically speeds up network performance. Your computer’s DNS cache, on the other hand, might get in your way and prevent you from visiting a proper site whether you are creating a website or adjusting domain settings.
Viruses and network attacks are only two of the many factors that might cause the DNS cache flushing to become corrupt. If that occurs, some well-known websites’ IP address mapping ends up manipulated.
DNS Cache Flushing removes all accumulated DNS lookup information. After that, whenever your computer makes a lookup request, DNS servers provide it with updated information. Listed below are instructions for flushing DNS on macOS, Windows, and Linux.
What is DNS Cache?
DNS cache is a method used by Linux, and Windows, along with macOS to store name resolution data. Having the IP addresses for the domains that are being searched in the cache speeds up project loading times. The technology provides replies to queries from the cache rather than needing to divert to flushing DNS cache servers.
Listed below are the data in the DNS cache:
- data from sources
- Record format
- document name
- Time to Live (TTL)
- Class
- Size of the resource data
How To Flush DNS Cache on Mac?
With respect to the OS X and macOS edition you are using, you’ll find a number of different commands you can use to flush the DNS cache on mac.
This article explains how to remove the DNS on macOS Mojave (10.14) and afterward lists the commands for different versions in a list because the process is the same on all of them.
When using macOS Mojave (version 10.14) flush the DNS by:
The flush DNS cache on macOS Mojave can be cleared using the Terminal program:
- Use your favorite method to launch the terminal.app program. Applications -> Utilities is where you can start the app, along with you can use Command + Space to start Spotlight and type in “Terminal” to start the software.
- Click the Return key after typing sudo killall -HUP mDNSResponder
- Press Return after entering the administrator passwords for the account.
When the procedure completes, no notification gets sent. But you may modify that by adding another command.
Keep in mind that once the initial command, enter some text whenever you’d like to receive an audio message when the DNS flush cache gets finished. For instance:
- sudo killall -HUP mDNSResponder; communicate that the dns cleared successfully
Previous versions of macOS or Mac OS X can use the flush DNS command
The commands for the vast majority of macOS and Mac OS X editions get displayed in the table below for flushing the DNS cache. They can get copied and pasted directly into your terminal via the table itself.
Terminal Command | Versions of Mac OS X and macOS |
sudo killall -HUP mDNSResponder | Mojave (version 10.14)High Sierra (version 10.13)Sierra (version 10.12)Mountain Lion (version 10.8)Lion (version 10.7) |
sudo dscacheutil -flushcache sudo killall -HUP mDNSResponder | El Capitan (version 10.11)Mavericks (version 10.9) |
sudo discoveryutil mdnsflushcache sudo discoveryutil udnsflushcaches | Yosemite (version 10.10) |
sudo dscacheutil -flushcache | Snow Leopard (version 10.6)Leopard (version 10.5) |
lookupd -flushcache | Tiger (version 10.4) |
How to Flush DNS in Windows?
It takes little time or effort to clear the DNS cache windows. For practically all Windows computers, the process is the same. We’ll be utilizing Windows 10 for the example below.
When using Windows, flush the DNS:
1. Launch the Command Prompt as an administrator. To find the command prompt in the search results, click the Start Menu then begin typing.
2. When the prompt appears, write ipconfig /flushdns and press Enter.
3. It should just require a short amount of time. When it gets finished, you ought to get the following DNS Resolver Cache confirmation message:
Your computer’s DNS Caching database has become free of any information. When the next time your system submits a DNS query, DNS servers should return the most recent and accurate IP mapping.
Recommended: How to Start, Stop, and Restart Nginx in Linux? (2 Methods)
How to Flush DNS Cache in Linux?
In comparison to Windows and Mac computers, the distributions of Linux differ slightly. The DNS cache flush service used by each Linux distribution could change. Some distributions, especially Ubuntu, don’t even have a built-in DNS server.
The service you use and if it has been set up by default will depend on your distribution. Among these are BIND (Berkely Internet Name Domain), dnsmasq, as well as NCSD (Name Service Caching Daemon).
Start a terminal window for each distribution you want to use. Clearing the DNS cache for the service or services that your Linux system is running requires you to hold down Ctrl+Alt+T on your keyboard and enter the associated command.
Eliminate Local NCSD DNS Cache
To erase your Linux computer’s NCSD DNS cache, run the following command:
sudo /etc/init.d/nscd restart
Whenever prompted, put in your password. The NCSD service is immediately stopped and restarted by the process.
Clear Local DNS Cache for dnsmasq
For your Linux computer’s dnsmasq DNS cache to get cleared, run the following command:
sudo /etc/init.d/dnsmasq restart
When the terminal prompts you, reenter your password. Once the service resumes after stopping, you can observe the response.
Get Rid of Local BIND DNS Cache
Several commands can get used to clear BIND’s DNS cache when BIND is your DNS provider. It’s possible that your password will get required to complete the process.
- sudo /etc/init.d/named restart
- sudo rndc restart
- sudo rndc exec
Keep in mind that when conducting a DNS cache flush, BIND also lets you focus on particular domains. All you have to do is add the domain name and flushname to the sudo rndc command. For example, the following:
sudo rndc flushname serverwala.com
Also Read: Steps to Unzip/Extract tar.gz Files in Linux Using Command Line
Conclusion
The methods for clearing or flushing the DNS cache on Linux, Windows, as well as macOS systems are finally covered. Complete the steps above according to the operating system of your computer or internet browser to delete the DNS cache. Without the enormous work done by Domain Name Systems, the Internet as we know it nowadays would not exist. It’s crucial to flush DNS cache because as users, we might not be familiar with all the steps before we can view a webpage or get an email.