sitelink1 https://phoenixnap.com/kb/how-to-flush-dns-cache 
sitelink2  
sitelink3  
extra_vars6  

Introduction

DNS cache can be corrupted for a number of different reasons, including network attacks or viruses. When that happens, IP address mapping becomes corrupted for certain popular websites.

For example, instead of going to www.facebook.com, your browser may redirect you to an IP address of a malicious website that an attacker inserted in your computer’s DNS records. Or, you may get a large number of 404 errors.

 

 

Clearing DNS cache deletes all saved DNS lookup information. Your computer then gets updated data from DNS servers next time it sends a lookup request. Learn how to flush DNS on in Windows, MacOS, & Linux below.

 

What is DNS Cache?

Linux, Windows, and macOS save name resolution information in the form of DNS cache. This speeds up project load times since the cache contains IP addresses for the queried domains. Instead of having to reroute to DNS servers, the system answers queries from the cache.

The DNS cache contains the following information:

  • Resource data
  • Record type
  • Record name
  • TTL (time to live)
  • Class
  • Resource data length

How to Flush DNS in Windows

Clearing DNS cache is an easy and quick process. The procedure is the same for almost all Windows systems. Foe the example below, we will be using Windows 10.

To flush DNS on your Windows machine:

1. Load the Command Prompt as an administrator. Open the Start Menu and start typing command prompt until you see it in the results.

open-command-prompt.png

2. Type ipconfig /flushdns when the prompt loads and hit Enter on the keyboard.

 

flush-dns-command-windows.png

 

3. The process should take only a few seconds. You should see the DNS Resolver Cache confirmation message when it’s done:

how-dns-works-flush-windows3.png

The DNS Cache database on your computer is now clear. You should get the correct and updated IP mapping from DNS servers next time your machine sends a DNS query.

How To Flush DNS Cache on Mac

There are a few different commands to use for flushing DNS cache on OS X and macOS depending on the version you are running.

As the procedure is the same on all versions, this article details how to clear DNS on macOS Mojave (10.14) and then list the commands for other versions in a table.

Flush DNS on macOS Mojave (version 10.14)

how-dns-works-flush-macos1.png

 

how-dns-works-flush-macos2.png

To clear DNS cache on macOS Mojave, use the Terminal application:

  1. Run terminal.app using your preferred method. You can launch the app from Applications -> Utilities or press Command + Space to launch Spotlight and search for Terminal.
  2. Type in sudo killall -HUP mDNSResponder and hit Return on your keyboard.
  3. Enter the administrator password for the account in question and hit Return.

There is no notification when the process finishes. However, you can append another command to change that.


Note: If you want to hear an audio notification after the DNS flush is complete, type say some text after the first command. For example:

sudo killall -HUP mDNSResponder; say dns cleared successfully

Flush DNS Commands on Older macOS and Mac OS X Versions

The table below lists the commands for clearing the DNS cache on most macOS and Mac OS X versions. You can copy and paste them directly from the table into your terminal.

 

Mac OS X or macOS version Terminal Command
Mojave (version 10.14)
High Sierra (version 10.13)
Sierra (version 10.12)
Mountain Lion (version 10.8)
Lion (version 10.7)
sudo killall -HUP mDNSResponder
El Capitan (version 10.11)
Mavericks (version 10.9)
sudo dscacheutil -flushcache   sudo killall -HUP mDNSResponder
Yosemite (version 10.10) sudo discoveryutil mdnsflushcache   sudo discoveryutil udnsflushcaches
Snow Leopard (version 10.6)
Leopard (version 10.5)
sudo dscacheutil -flushcache
Tiger (version 10.4) lookupd -flushcache

 

How to Flush DNS Cache in Linux

Linux distributions are a bit different from Windows and Mac machines. Each Linux distribution might use a different DNS service. Some distributions, like Ubuntu, don’t have a default DNS service at all.

It depends on which service you have on your distribution and whether it is enabled by default. Some of them are NCSD (Name Service Caching Daemon), dnsmasq, and BIND (Berkely Internet Name Domain).

For every distribution, you need to launch a terminal window. Press Ctrl+Alt+T on your keyboard and use the corresponding command to clear the DNS cache for the service your Linux system is running.

Flush Local NCSD DNS Cache

Use this command to clear NCSD DNS cache on your Linux machine:

sudo /etc/init.d/nscd restart

Enter your password if necessary. The process stops and then starts the NCSD service within seconds.

Flush Local dnsmasq DNS Cache

Use this command to clear the dnsmasq DNS cache on your Linux machine:

sudo /etc/init.d/dnsmasq restart

Enter your password again, if the terminal asks you to. You will see the response when the service stops and starts again.

Flush Local BIND DNS Cache

If you use BIND for DNS service, there are a few commands you can use to flush its DNS cache. You may need to enter your password to finish the process.

sudo /etc/init.d/named restart
sudo rndc restart
sudo rndc exec

Note: BIND also allows you to target specific domains when performing a DNS flush. Just append flushname and the domain name to the sudo rndc command. For example:

sudo rndc flushname phoenixnap.com

Conclusion

You have now learned how to clear or flush DNS cache on Windows, Linux and macOS systems.

The Internet we use today would not be the same without the immense work that Domain Name Systems do. We, as users, may not be aware of how many processes occur before we see a webpage or receive an email, and that’s why it’s important to flush DNS.

번호 제목 글쓴이 날짜 조회 수
24 모바일 앱(안드로이드) 패킷 캡쳐하고 와이어샤크로 확인하기 file 황제낙엽 2023.08.05 297
23 NTLMv1 황제낙엽 2021.08.31 266
22 WireShark 패킷 로그에서 발견되는 메세지들의 의미 황제낙엽 2021.07.05 5460
» How to Flush DNS Cache Locally in Windows, macOS, & Linux file 황제낙엽 2021.07.01 37
20 DNS 관리 - TTL (Time To Live) 황제낙엽 2021.07.01 26
19 특정 포트가 오픈되어 있는지 확인하는 커맨드 명령어 황제낙엽 2021.06.11 30
18 Fiddler 프록시(Proxy) 설정하기 - 모바일 패킷 추적 (packet trace) file 황제낙엽 2021.03.26 71
17 wireshark로 패킷 헤더 확인하기 file 황제낙엽 2021.01.04 351
16 Stream index 란? 황제낙엽 2021.01.04 411
15 WireShark를 이용한 TCP/UDP 패킷 분석 secret 황제낙엽 2021.01.03 0
14 WireShark, 네트워크마이너(Networkminer) 를 이용하여 PCAP에 포함된 악성코드 여부를 판단하는 절차 알아보기 secret 황제낙엽 2021.01.03 0
13 WireShark를 이용한 ARP, ICMP, TCP, DHCP 캡처 및 분석하기 secret 황제낙엽 2021.01.02 1
12 repeater, hub, bridges, switches, router, VLAN(Virtual LAN) file 황제낙엽 2021.01.02 38
11 TCP Control Flag (TCP 제어 플래그 - FIN,ACK,SYN,URG,PSH,RST) file 황제낙엽 2020.12.31 131
10 TCP (Transmission Control Protocol, 전송 제어 프로토콜) file 황제낙엽 2020.12.31 25
9 L2, L3, L4, L7 스위치 file 황제낙엽 2020.12.24 471
8 피들러(Fiddler) AutoResponder file 황제낙엽 2020.11.04 126
7 L4 Sticky Session & Sticky Time 황제낙엽 2020.07.31 410
6 [ngrok] localhost 개발서버를 외부에 잠시 오픈 file 황제낙엽 2020.07.20 281
5 피들러(Fiddler) 활용 - binary Response 의 decode capture (응답데이터를 text string으로 저장) file 황제낙엽 2020.03.24 62