用 `resolvectl flush-caches` 清除 DNS 缓存
在基于 systemd 的 Linux(Ubuntu、Fedora、Debian 12+)上,本地 DNS 缓存由 systemd-resolved 管理——清缓存命令从旧的 systemd-resolve 改名后,很多人总想不起来。
运行 `resolvectl flush-caches` 立即清空 systemd-resolved 的全部 DNS 缓存,可用 `resolvectl statistics` 验证。
01命令
命令
$ resolvectl flush-caches02作用说明
systemd-resolved 会在本地缓存所有 DNS 应答,所以修改了 DNS 记录或切换网络后,你可能仍解析到旧 IP。`resolvectl flush-caches` 会立刻丢弃全部缓存条目(旧版本系统对应 `systemd-resolve --flush-caches`)。由于只是丢弃缓存,这条命令可以放心反复执行。
03风险
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- resolvectl(1) — Linux manual page依据: Documents `resolvectl flush-caches` which flushes all DNS caches of systemd-resolved, and `resolvectl statistics` to view cache size
最后验证: 2026-09-17 · 分类: 网络