Kau*_*ete 4 dns services systemd systemd-resolved
主要问题是:
# 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.
Run Code Online (Sandbox Code Playgroud)
这个问题是我通过执行以下步骤解决的:
apt-get update失败了。我首先遵循https://askubuntu.com/a/91590/1042537的答案
这解释了问题并指出了 DNS 的错误。
要配置dns服务器,我遵循/sf/answers/3812262051/。
我还# 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.
Run Code Online (Sandbox Code Playgroud)
当我尝试开始时,我遇到了主要问题。
因此网络名称解析无法启动。
我是一个新手贡献者。希望提出改进答案的建议!
尽管引发了很多错误,但#systemctl status systemd-resolved.service
主要问题是资源。
这个问题是由于没有tmp目录导致的var
即/var/tmp/缺席。
解决方案:
mkdir /var/tmp
chmod 777 /var/tmp
Run Code Online (Sandbox Code Playgroud)
777 权限对于网络服务器来说是一个不好的做法,因为它为每个用户提供读/写访问权限。所以请相应地使用它
然后为了启动服务,我执行了:
systemctl enable --now systemd-resolved.service
Run Code Online (Sandbox Code Playgroud)
然后,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.
Run Code Online (Sandbox Code Playgroud)
可以查看https://serverfault.com/a/1032451
有关 systemd 解析的名称解析视图的优质资源:
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