系统重启时名称服务器不存在

系统重启时名称服务器不存在

Ubuntu 18.04

我在系统重启时遇到了问题systemd resolve --status。以下是输出

$ sudo systemd-resolve status
status: resolve call failed: Unit dbus-org.freedesktop.resolve1.service not found.

以下是/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.

目前没有配置名称服务器,因此无法解析任何名称。但运行后就可以sudo systemctl restart systemd-resolved.service正常修复:

usr@pc:~$ sudo systemctl restart systemd-resolved.service
usr@pc:~$ 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.

nameserver 127.0.0.53

因此每次我重新启动笔记本电脑时都必须手动操作sudo systemctl restart systemd-resolved.service。有办法解决这个问题吗?

这是我的/etc/systemd/resolved.conf

$ cat /etc/systemd/resolved.conf 
[Resolve]
DNS=8.8.8.8
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

更新:我试图赞扬这句话DNS=8.8.8.8,但如果没有它,任何名字都无法解决。

UPD:resolv.conf定义为

$ ls -la /etc/resolv.conf 
lrwxrwxrwx 1 root root 29 Jun  5 23:40 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

UPD:系统重启时文件/run/systemd/resolve/stub-resolv.conf被删除,因此系统重启时符号链接/etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf无效。手动sudo systemctl restart systemd-resolved.service修复了该问题。

看起来问题在于它systemd-resolved在启动时根本无法运行(由于某些不清楚的原因)。

相关内容