主要问题是:
# systemctl status systemd-resolved.service
systemd-resolved.service -
Network Name Resolution Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
Active: failed (Result: resources) since Wed 2021-05-19 11:15:15 UTC; 23s ago
Docs: man:systemd-resolved.service(8)
https://www.freedesktop.org/wiki/Software/systemd/resolved
https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
May 19 11:15:15 kv-server systemd[1]: systemd-resolved.service: Service has no hold-off time, scheduling restart.
May 19 11:15:15 kv-server systemd[1]: systemd-resolved.service: Scheduled restart job, restart counter is at 5.
May 19 11:15:15 kv-server systemd[1]: Stopped Network Name Resolution.
May 19 11:15:15 kv-server systemd[1]: systemd-resolved.service: Start request repeated too quickly.
May 19 11:15:15 kv-server systemd[1]: systemd-resolved.service: Failed with result 'resources'.
May 19 11:15:15 kv-server systemd[1]: Failed to start Network Name Resolution.
我通过以下步骤解决了这个问题:
apt-get update
失败了。我开始按照以下答案https://askubuntu.com/a/91590/1042537
这解释了该问题并将错误指向了 DNS。
为了配置 DNS 服务器,我按照https://stackoverflow.com/a/54460886/14950576。
我也# chattr +i /etc/resolv.conf
这样做了,这样 resolv.conf 就不会被 DHCP 更新
我试过了# ping google.com
但还是失败了。
我发现了一个坏的符号链接/etc/resolv.conf -> /run/systemd/resolve/stub-resolve.conf
,所以我尝试访问/run/systemd/resolve/stub-resolve.conf
收到错误,表示没有目录/run/systemd/resolve
所以我跟着https://unix.stackexchange.com/a/613143并得知那systemd-resolved.service
并没有运行。
我得到的错误是
# systemctl enable --now systemd-resolved.service
Job for systemd-resolved.service failed because of unavailable resources or another system error.
See "systemctl status systemd-resolved.service" and "journalctl -xe" for details.
当我尝试开始这样做时,我遇到了主要问题。
因此网络名称解析无法启动。
答案1
我是一名新手投稿人。希望得到建议来改进答案!!
尽管很多错误都是由#systemctl status systemd-resolved.service
资源问题引发的。
此问题是由于缺少tmp
目录引起的var
即/var/tmp/
缺席。
解决方案:
mkdir /var/tmp
chmod 777 /var/tmp
777 权限是不好的做法对于网络服务器,因为它为每个用户提供读/写权限。因此请适当使用它
然后为了启动服务,我执行以下操作:
systemctl enable --now systemd-resolved.service
然后,ping google.com
给出成功的结果。
解决方案的灵感来自于https://www.raspberrypi.org/forums/viewtopic.php?t=249619
PS:对于其他错误:
May 19 11:15:15 kv-server systemd[1]: systemd-resolved.service: Service has no hold-off time, scheduling restart.
May 19 11:15:15 kv-server systemd[1]: systemd-resolved.service: Scheduled restart job, restart counter is at 5.
您可以查看https://serverfault.com/a/1032451
有关 systemd-resolved 名称解析的优质资源请查看:
https://www.youtube.com/watch?v=DtFjrJdnWAU
https://moss.sh/name-resolution-issue-systemd-resolved/
https://unix.stackexchange.com/questions/328131/how-to-troubleshoot-dns-with-systemd-resolved