使用 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管家永不眠:拆解Gemini Spark的云端Agent架构

  • u2
  • 5月 22, 2026
  • 50 views

CodeGraph 让 AI 编程助手拥有”代码知识图谱”

  • u2
  • 5月 19, 2026
  • 171 views

MCP Gateway 完全指南:企业级 AI Agent 的控制平面

  • u2
  • 5月 17, 2026
  • 59 views

技术深度解析:Model Context Protocol (MCP)

  • u2
  • 5月 16, 2026
  • 66 views

Hermes Agent 自动学习与成长原理深度解读

  • u2
  • 5月 14, 2026
  • 115 views

Agent Memory + Skills 双轮驱动 Memori Labs × Anthropic Dreaming 执行记忆 vs 会话记忆,如何构建持续进化的 Agent

  • u2
  • 5月 11, 2026
  • 111 views
Agent Memory + Skills 双轮驱动 Memori Labs × Anthropic Dreaming 执行记忆 vs 会话记忆,如何构建持续进化的 Agent