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

TraceClaw:企业级透明可控智能体,全行为审计+零信任执行

  • u2
  • 6月 13, 2026
  • 19 views

一年前让英伟达蒸发6000亿美元的中国AI,现在被黄仁勋请上了CES的PPT

  • u2
  • 6月 7, 2026
  • 70 views

当AI开始”破坏”:Anthropic告诉我们,每个用户都该重新审视自己的使用方式

  • u2
  • 6月 6, 2026
  • 74 views

10款大模型同台黑客测试:GPT-5.5拿了王冠,DeepSeek便宜15倍,Gemini直接退赛

  • u2
  • 6月 5, 2026
  • 61 views

30天,0天,90天:一纸行政令,把AI公司的”自由发布”踩了急刹车

  • u2
  • 6月 4, 2026
  • 81 views

AI很厉害,可你省的人力费还不够买Token!

  • u2
  • 6月 2, 2026
  • 94 views