Post

How to Flush DNS on Windows/Mac/Linux

How to Flush DNS

Why is DNS flushing needed?

Flushing the DNS cache means clearing out all stored domain name and IP address entries from a computer’s temporary storage (the cache). When you visit a website or connect to a remote server, your device often saves (or caches) the domain-to-IP-address resolution for a certain period. This caching mechanism speeds up subsequent requests to the same domain names because your system can quickly reference its cache without needing to query an external DNS server again

What are some common reasons to need to flush DNS?

Website IP Address Changes: If a website has recently moved to a new server, its IP address might change. Your system’s cached entry for that domain might still point to the old IP address, which could cause connection issues. Flushing the DNS cache ensures that your computer queries the DNS server again for the domain and retrieves the new IP address.

Propagation Delays: Sometimes after changing DNS records for a domain, you might want to see the changes immediately. Cached DNS entries can prevent this, so developers or administrators might flush the DNS cache to speed up this process.

ISP or DNS Server Changes: If you switch to a new DNS server or if your ISP makes significant changes, flushing the cache can help in picking up the new configurations faster.

Local Development: Web developers often modify their local host files to redirect domain names to local development servers. Flushing the DNS cache ensures that the system picks up these changes promptly.

Corrupted Cache Entries: Rarely, the DNS cache can become corrupted with invalid or wrong entries. This might cause connection errors to certain websites. Clearing the cache can resolve these issues.

Network Changes: If there are changes in your local network—like adding new devices, servers, or changing configurations—it might be helpful to flush the DNS cache to ensure your computer has the most up-to-date network information.

Privacy Concerns: The DNS cache could be used to see which websites have been accessed from a computer. Flushing it can clear this record, which could be a privacy concern for some users.

DNS Poisoning Attacks: In some cyber-attacks, an attacker can introduce malicious DNS entries into the cache. Flushing the cache can be a step in remediation, though additional steps would be needed to fully address the attack.

How to Flush DNS: Windows

Open an Administrative PowerShell or Command Prompt and type the following command:

1
ipconfig /flushdns

How to Flush DNS: MacOS

Open a terminal and execute the following command:

1
sudo killall -HUP mDNSResponder

What does this command do?

  • sudo - Runs command as super user
  • killall - Sends a signal to processes
  • -HUP - Represents the ‘HangUP’ signal, which instructs the process to restart and re-read its configuration files. It’s a way of telling the process to refresh itself without fully terminating it.
  • mDNSResponder - The name can be broken down into “mDNS” (Multicast Domain Name System) and “Responder.” Essentially, it’s the service that responds to mDNS queries.

What is mDNSResponder?

mDNSResponder is a system service that runs on macOS and some other operating systems. Its primary function is to facilitate the use of DNS-SD (DNS Service Discovery) and mDNS (Multicast Domain Name System) protocols.

DNS-SD (DNS Service Discovery): DNS-SD is a way of using standard DNS programming interfaces, servers, and packet formats to browse the network for services. It’s a way for devices and applications to advertise their services on a local network. When combined with mDNS, it allows for seamless service and device discovery without any centralized configuration or service.

On macOS, mDNSResponder handles both mDNS and regular unicast DNS requests. This service is essential for tasks like:

  • Helping your computer find printers on your local network.
  • Discovering and connecting to other computers using Apple’s “AirDrop” feature.
  • Streaming audio and video to an Apple TV or other devices using “AirPlay.”
  • Other applications and services that rely on local network discovery.

How to Flush DNS: Linux

Open a terminal and execute the following command:

1
sudo systemctl restart systemd-resolved
This post is licensed under CC BY 4.0 by the author.

© Michael Baas. Some rights reserved.

Using the Chirpy theme for Jekyll.