使用 discoveryutil 清理 MAC OS DNS 缓存

本文介绍如何使用discoveryutil工具清理MAC OS(Yosemite)的DNS缓存,啥是DNS这里就不赘述了:)
你需要使用终端(Terminal)来清理DNS缓存,可以用Spotlight启动终端或者从/Applications/Utilities/里面找到,最终目标是清理MDNS和UDNS两种DNS缓存。

首先:打开MAC OS terminal
Control+Spase 输入:终端
mac-open-terminal

然后在终端执行 discoveryutil 命令:
清理 MDNS (Multicast DNS) Cache

sudo discoveryutil mdnsflushcache

回车,需要输入管理员密码

清理 UDNS(Unicast DNS) Cache

sudo discoveryutil udnsflushcaches

回车,需要输入管理员密码

一步清理OS X Yosemite所有DNS缓存

sudo discoveryutil mdnsflushcache;sudo discoveryutil udnsflushcaches;say flushed

执行后没有返回结果输出:

MacBook-Pro:~ sudops.com$ sudo discoveryutil mdnsflushcache;sudo discoveryutil udnsflushcaches;say flushed
Password:
MacBook-Pro:~ sudops.com$ 

下面是查看现有的cache MDNS/UDNS情况:

sudo discoveryutil mdnscachestats
sudo discoveryutil udnscachestats

我的执行结果如下:

MacBook-Pro:~ sudops.com$ sudo discoveryutil udnscachestats

UDNS Cache Stats: Ext Resolver on en1
UDNS Cache Stats: Resolver domain [default], type Unicast, ifIndex 6, port 0, timeout 30, A yes, AAAA no, serviceID 0, scope None, order 0
  server(s) 8.8.8.8, 8.8.4.4
UDNS Cache Stats: Cached 115 of 5000, table size 256, hash coverage 0.22, max miss depth 8, avg miss depth 0.38, reclaims 0
Cached records after aging 89
UDNS Cache Stats: Ext Resolver on en1
UDNS Cache Stats: Resolver domain [default], type Unicast, ifIndex 6, port 0, timeout 30, A yes, AAAA no, serviceID 0, scope InterfaceID, order 0
  server(s) 8.8.8.8, 8.8.4.4
UDNS Cache Stats: Cached 0 of 5000, table size 256, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0

看到我的DNS服务器是:8.8.8.8, 8.8.4.4,
UDNS缓存状态:UDNS Cache Stats: Cached 115 of 5000, table size 256, hash coverage 0.22 …

MacBook-Pro:~ sudops.com$ sudo discoveryutil mdnscachestats
MDNS Cache Stats: lo0: Cached 0 of 7500, table size 16, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0
MDNS Cache Stats: vboxnet0: Cached 0 of 7500, table size 256, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0
MDNS Cache Stats: awdl0: Cached 0 of 7500, table size 256, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0
MDNS Cache Stats: en1: Cached 0 of 7500, table size 128, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0

最后可以使用dig/nslookup命令查询域名的解析情况:
如:
dig google.com

MacBook-Pro:~ sudops.com$ dig google.com

; <<>> DiG 9.8.3-P1 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46653
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		74	IN	A	74.125.23.100
google.com.		74	IN	A	74.125.23.101
google.com.		74	IN	A	74.125.23.102
google.com.		74	IN	A	74.125.23.113
google.com.		74	IN	A	74.125.23.138
google.com.		74	IN	A	74.125.23.139
...

u2

Related Posts

unbound 清除 DNS 缓存

[摘要] 使用了unbound做的DNS缓存,DNS的查询性…

Read more

Jigdo 一种专门为 Debian 系统设计的下载工具

Jigdo 一种为Debian包设计的下载工具,jigdo …

Read more

You Missed

AI安全护栏:保护还是束缚?一场不对称的战争

  • u2
  • 3月 11, 2026
  • 20 views

从”养虾”到AI Agent爆发:2026年技术圈的新范式转移

  • u2
  • 3月 9, 2026
  • 44 views

提示词注入:AI时代最危险的漏洞,正在吞噬你的数据

  • u2
  • 3月 7, 2026
  • 79 views
提示词注入:AI时代最危险的漏洞,正在吞噬你的数据

潘多拉魔盒已打开:开源AI攻击平台正在血洗全球防火墙

  • u2
  • 3月 4, 2026
  • 86 views
潘多拉魔盒已打开:开源AI攻击平台正在血洗全球防火墙

雇佣AI员工,花钱上班:开发者的新”职场”荒诞剧

  • u2
  • 3月 1, 2026
  • 83 views
雇佣AI员工,花钱上班:开发者的新”职场”荒诞剧

OpenClaw 完整使用指南:自托管 AI Agent 的架构与实战

  • u2
  • 2月 25, 2026
  • 206 views
OpenClaw 完整使用指南:自托管 AI Agent 的架构与实战