Debian 域名解析失败(resolv.conf)?
resolv.conf 是手动写的还是 systemd-resolved 管理的,决定排查路线。本文按「分清谁管 → 走对的路径 → 验证解析」三步修复。
简短答案
域名解析失败,先看 resolv.conf 是被 systemd-resolved 管理还是被手动写过。最小安装的 Debian 13.7 DVD 默认走 systemd-resolved,直接手写 resolv.conf 会被服务重发覆盖、且改完不生效。先分清管理权,再走对路径。
现象对照
| 现象 | 判断 |
|---|---|
| resolv.conf 是软链到 systemd-resolve 路径 | 系统托管,改 resolv.conf 本身无效 |
| 是普通文件且写死 nameserver | 手动写过,重启后失效 |
resolvectl status 报 no link |
无活动网络接口,解析无从谈起 |
排查步骤
ls -l /etc/resolv.conf
resolvectl status
sudo systemd-resolve --unflush-caches
sudo apt install dnsutils
dig @8.8.8.8 example.com +short # 直接指上游验证链路
手动指定 nameserver 的正确姿势:写入 netplan/systemd 网络配置,不直接改 resolv.conf;验证用 dig 指定上游 IP,排除是链路还是配置问题。Debian 侧说明见 Debian 发行条目,Ubuntu 桌面/服务器机制对照 Ubuntu 发行条目。
操作小结
ls -l /etc/resolv.conf先分清托管还是手动- 托管走 netplan/systemd 配置,不手写
dig @上游IP验证链路是否本身可达- 改完
resolvectl --unflush-caches清缓存再测