使用 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

Anthropic 指控阿里蒸馏攻击:AI 军备竞赛的拐点

  • u2
  • 6月 25, 2026
  • 70 views

当AI开始吃自己:数据污染正在成为大模型行业最隐秘的危机

  • u2
  • 6月 25, 2026
  • 85 views

Google 用 AI「杀死」Google

  • u2
  • 6月 22, 2026
  • 94 views

封禁Fable 5:当美国政府成为AI的”守门人”

  • u2
  • 6月 21, 2026
  • 169 views

27亿美元没留住的人,奥特曼等了十年

  • u2
  • 6月 19, 2026
  • 84 views

OpenAI Codex 发布角色插件:当AI开始理解「分析师」和「销售」是两种不同的物种

  • u2
  • 6月 15, 2026
  • 139 views
OpenAI Codex 发布角色插件:当AI开始理解「分析师」和「销售」是两种不同的物种