| 场景 | 域名解析失败/结果不对 |
|---|---|
| 组合 | getent + dig + resolvectl |
系统实际解析
系统实际解析
getent hosts app.example.com # 走 nsswitch 的真实结果(含 /etc/hosts)
grep -v '^#' /etc/hosts | grep -i app
cat /etc/nsswitch.conf | grep hosts逐级对照
逐级对照
dig +short app.example.com # 默认 DNS
dig +short @1.1.1.1 app.example.com # 公共 DNS
dig +short @ns1.example.com app.example.com # 权威直问
dig +trace app.example.com | tail -20结果不对时
结果不对时
resolvectl status # systemd-resolved 分流配置
resolvectl flush-caches # 清本地缓存
curl -sS --resolve app.example.com:443:10.0.0.9 https://app.example.com/ -I # 绕过 DNS 直测目标 IP「只有某台机器解析不对」优先查 /etc/hosts 与 nsswitch;「全网都不对」查权威与 TTL 缓存。