用 dscacheutil 查看 Mac 实际解析到的地址
通过目录服务查询主机名解析结果——与系统应用实际走的路径一致,适合验证 DNS 刷新是否生效。
运行 dscacheutil -q host -a name example.com,输出中的 ip_address 就是系统当前解析到的地址。
01命令
命令
$ dscacheutil -q host -a name example.com02作用说明
与直接询问 DNS 服务器的 dig 不同,dscacheutil 走的是 macOS 目录服务层——应用联网时用的正是这条路径——所以它的结果反映了系统此刻真实的解析情况(含缓存值)。-q host 表示查询主机记录,-a name 指定要查的主机名。修改 DNS 后的常用流程是:先刷新缓存,再运行 dscacheutil,确认 ip_address 已经变成新地址。
03风险
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- dscacheutil - Gather information and statistics from the Directory Services cache依据: Documents `-q <category>` with categories including `host`, and `-a <attribute> <value>` (e.g. `-a name <hostname>`) to query cached directory/DNS entries.
- dscacheutil(1) man page依据: Man page for dscacheutil: `-q host -a name <host>` performs a host query through the Directory Services cache, showing ip_address and other returned attributes.
最后验证: 2026-09-19 · 分类: 网络