升级到 Xubuntu 19.04 桌面后,如何调试“名称解析暂时失败”错误?

升级到 Xubuntu 19.04 桌面后,如何调试“名称解析暂时失败”错误?

我最近将 Xubuntu 从 18.10 升级到了 19.04,从那时起,每当我尝试 ping 域名时,都会看到“名称解析暂时失败”错误。我使用的是台式电脑,通过单个以太网连接到调制解调器/路由器。多年来,我一直在升级同一个 Xubuntu 安装;我不确定我上次全新安装是什么时候。

Ping IP 地址可以正常工作,只有 ping 域名才会导致此错误。

如果我断开然后使用网络管理器面板小程序重新连接以太网连接(下面的屏幕截图),错误就会消失,并且互联网连接将正常工作,直到我重新启动计算机。

网络管理器面板小程序

这些是我的连接设置: 以太网连接设置

在新启动时,这些是我为尝试诊断问题而运行的一些命令的简要结果通过断开连接并重新连接来解决问题:

$ systemd-resolve --status

Link 2 (eth0)
      Current Scopes: DNS
DefaultRoute setting: yes
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 8.8.8.8
                      8.8.4.4
          DNS Domain: ~.

$ nmcli device show eth0

IP4.ADDRESS[1]:                         192.168.1.8/24
IP4.GATEWAY:                            192.168.1.1
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 192.168.1.1, mt = 100
IP4.ROUTE[2]:                           dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 100
IP4.ROUTE[3]:                           dst = XXX.XXX.0.0/16, nh = 0.0.0.0, mt = 1000
IP4.DNS[1]:                             8.8.8.8
IP4.DNS[2]:                             8.8.4.4

$ systemctl status resolvconf

● resolvconf.service - Nameserver information manager
   Loaded: loaded (/lib/systemd/system/resolvconf.service; enabled; vendor preset: enabled)
   Active: active (exited) since Tue 2019-08-06 10:09:40 CEST; 6min ago

$ systemctl status NetworkManager

● NetworkManager.service - Network Manager
   Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-08-06 10:10:20 CEST; 5min ago
...
Aug 06 10:10:31 xxxx NetworkManager[1136]: <info>  [1565079031.8637] device (eth0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Aug 06 10:10:31 xxxx NetworkManager[1136]: <info>  [1565079031.8640] device (eth0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Aug 06 10:10:31 xxxx NetworkManager[1136]: <info>  [1565079031.8646] manager: NetworkManager state is now CONNECTED_LOCAL
Aug 06 10:10:32 xxxx dhclient[1397]: bound to 192.168.1.8 -- renewal in 37516 seconds.
Aug 06 10:10:32 xxxx NetworkManager[1136]: <info>  [1565079032.2838] manager: NetworkManager state is now CONNECTED_SITE
Aug 06 10:10:32 xxxx NetworkManager[1136]: <info>  [1565079032.2840] policy: set 'Wired connection 1' (eth0) as default for IPv4 routing and DNS
Aug 06 10:10:32 xxxx NetworkManager[1136]: <info>  [1565079032.2844] device (eth0): Activation: successful, device activated.
Aug 06 10:10:32 xxxx NetworkManager[1136]: <info>  [1565079032.2851] manager: NetworkManager state is now CONNECTED_GLOBAL
Aug 06 10:10:32 xxxx NetworkManager[1136]: <info>  [1565079032.2856] manager: startup complete
Aug 06 10:12:14 xxxx NetworkManager[1136]: <info>  [1565079134.0454] agent-manager: req[0x56068d7b9090, :1.89/org.freedesktop.nm-applet/1000]: agent registered

我的 netplan 配置目录是空的:

$ ls /etc/netplan -a

. ..

我不知道是否/etc/network/interfaces仍在使用:

$ cat /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

# auto eth0
# iface eth0 inet dhcp

您对如何解决此问题有什么建议吗?我希望 DNS 能够正常工作,而无需在每次启动后断开并重新连接以太网连接。谢谢!

编辑#1

$ ls -al /etc/resolv.conf

lrwxrwxrwx 1 root root 29 Jun 30  2015 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

编辑#2

/etc/resolv.conf这些是启动后立即显示的内容:

$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

/etc/resolv.conf这些是断开并重新连接以太网连接后的内容:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53

答案1

我建议您重新创建丢失的 netplan 文件;从终端:

sudo nano /etc/netplan/01-network-manager-all.yaml

添加以下内容:

network:
  version: 2
  renderer: NetworkManager

间距和缩进至关重要,必须正确。仔细校对两遍。保存(Ctrl+o 后按 Enter)并退出(Ctrl+x)文本编辑器。然后:

sudo netplan generate
sudo netplan apply

接下来,对于您的情况,resolv.conf 未按预期指向 systemd。因此,我建议您删除并重新创建链接:

sudo rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

重新启动并告诉我们是否有任何改进。

相关内容