查看系统正在使用的 DNS 服务器
显示 systemd-resolved 实际生效的各连接解析设置。
运行 resolvectl status,找到活动接口下的 DNS Servers 一行——那就是系统实际使用的解析服务器。
01命令
命令
$ resolvectl status | grep -A2 'DNS Servers'02作用说明
新版 Ubuntu 和 Fedora 不再老老实实读 /etc/resolv.conf,DNS 由 systemd-resolved 按网卡分别管理,resolvectl status 就是查看它的入口。想知道“我的 Pi-hole/AdGuard 怎么没生效?”跑一下就能看出自定义服务器有没有挂到对应接口上,还是仍然在用路由器的 DNS。全局 DNS 在最上面,各接口的在其下方。
03风险
!注意: 没有 systemd-resolved 的发行版没有这个命令——改看 /etc/resolv.conf;接口级 DNS 只有在域名匹配该接口的搜索域时才会覆盖全局 DNS。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- resolvectl(1) — manual page依据: resolvectl status shows the DNS servers and domains configured per link by systemd-resolved.
- systemd-resolved — Arch Wiki依据: resolvectl status is the way to inspect which DNS servers systemd-resolved is using per interface.
最后验证: 2026-09-18 · 分类: 网络
06相关方案
用 `resolvectl flush-caches` 清除 DNS 缓存
在基于 systemd 的 Linux(Ubuntu、Fedora、Debian 12+)上,本地 DNS 缓存由 systemd-resolved 管理——清缓存命令从旧的 systemd-resolve 改名后,很多人总想不起来。
用 dig 查询 DNS 记录
查询域名的任意 DNS 记录类型,既可以输出精简结果,也可以查看包含报文头和 TTL 的完整应答。
用 `ip -br a` 以紧凑表格显示 IP 地址
一条命令就能把每个网卡的名称、状态和 IPv4/IPv6 地址打印成简短表格——这是取代又长又难记的 `ifconfig` 和冗长的 `ip addr` 输出的现代做法。