如何清除 DNS 缓存(macOS、FreeBSD、Ubuntu、CentOS、Windows)
1. Apple macOS
打开终端,输入如下命令:
1
|
sudo killall -HUP mDNSResponder; sudo dscacheutil -flushcache
|
2. FreeBSD
FreeBSB 自带 nscd(Name Service Cache Daemon),默认没有启用。
运行如下命令启动 nscd 并设置为开机自动运行 (sysin):
1
|
sudo service nscd enable && sudo service nscd start
|
清除缓存即重启 nscd 服务:
1
|
sudo service nscd restart
|
3. Ubuntu
Ubuntu 默认运行 systemd-resolve daemon 用于名称服务缓存。
1
|
|
备注:Ubuntu 也可以配置使用 nscd。
4. CentOS
CentOS 默认不存在 Client 端的 DNS 缓存。
参看:
flush client dns cache
flush dns cache
通常使用 nscd 来启用 dns 缓存:
1
|
yum -y install nscd
|
清除缓存即重启 nscd 服务:
1
|
systemctl restart nscd
|
5. Microsoft Windows
清除 dns 缓存内容:
1
|
ipconfig/flushdns
|
查看 dns 缓存内容:
1
|
ipconfig/displaydns
|
Windows 下的 DNS Cache 是由 DNS Client 后台进程控制的,你可以在 “服务” 中将其关闭,这样 windows 就不会进行 DNS 缓存,每次都将直接查询 DNS Server。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)