如何清除 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
2
3
4
5
6
7
8
# Step 1. 查看 DNS 缓存状况
sudo systemd-resolve --statistics

# Step 2. 清除 DNS 缓存,systemd-resolve daemon 默认在所有的 Ubuntu 系统上运行
sudo systemd-resolve --flush-caches

# Step 3. 正在查看验证结果 (sysin)
sudo systemd-resolve --statistics

备注:Ubuntu 也可以配置使用 nscd。

4. CentOS

CentOS 默认不存在 Client 端的 DNS 缓存。

参看:

flush client dns cache

flush dns cache

通常使用 nscd 来启用 dns 缓存:

1
2
yum -y install nscd
systemctl enable --now nscd

清除缓存即重启 nscd 服务:

1
systemctl restart nscd

5. Microsoft Windows

清除 dns 缓存内容:

1
ipconfig/flushdns

查看 dns 缓存内容:

1
ipconfig/displaydns
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值