systemctl status systemd-resolved.service
回报
systemd-resolved.service - Network Name Resolution
Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-02-01 19:47:24 CET; 15min ago
Docs: man:systemd-resolved.service(8)
man:org.freedesktop.resolve1(5)
https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
Main PID: 65445 (systemd-resolve)
Status: "Processing requests..."
Tasks: 1 (limit: 36023)
Memory: 1.6M
CPU: 3.572s
CGroup: /system.slice/systemd-resolved.service
└─65445 /lib/systemd/systemd-resolved
Feb 01 19:47:20 srvides00 systemd[1]: Starting Network Name Resolution...
Feb 01 19:47:24 srvides00 systemd-resolved[65445]: Positive Trust Anchors:
Feb 01 19:47:24 srvides00 systemd-resolved[65445]: . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d
Feb 01 19:47:24 srvides00 systemd-resolved[65445]: Negative trust anchors: home.arpa 10.in-addr.arpa 16.172.in-addr.arpa 17.172.in-addr.arpa 18.172.in-addr.arpa 19.172.in-addr.arpa 20.172.in-addr.arpa 21.172.in-addr.arpa 22.172.in-addr.>
Feb 01 19:47:24 srvides00 systemd-resolved[65445]: Failed to open configuration file **'/etc/systemd/resolved.conf': Permission denied**
Feb 01 19:47:24 srvides00 systemd-resolved[65445]: Failed to parse configuration file: Permission denied
Feb 01 19:47:24 srvides00 systemd-resolved[65445]: **Failed to stat /etc/resolv.conf: Permission denied**
Feb 01 19:47:24 srvides00 systemd[1]: Started Network Name Resolution.
请在下面找到权限详细信息
-rwxr-xr-x 1 root root 1406 Apr 7 2022 /etc/systemd/resolved.conf
lrwxrwxrwx 1 root root 39 Jan 20 2021 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
可能出了什么问题,我们使用的是 Ubuntu 22.04.1
ping /etc/hosts 中的任何条目时出现“名称解析暂时失败”
答案1
关于“名称解析暂时失败”尝试 ping /etc/hosts 中的条目时出现错误消息,这可能表明 systemd 解析的服务无法将主机名正确解析为 IP 地址。要排除故障,您可以尝试重新启动 systemd-resolved 服务,检查 /etc/resolv.conf 和 /etc/systemd/resolved.conf 文件的内容以确保它们配置正确,并检查 /etc 中的条目是否正确/hosts 文件是正确的。
这可能表明文件的权限有问题。已解析的服务可能需要对配置文件的读取访问权限才能正常工作。似乎正在运行解析的服务,但没有足够的权限来访问所需的文件。
建议检查配置文件的权限,并确保它们的设置使得解析的服务可以访问它们。例如,文件 /etc/systemd/resolved.conf 的所有者应该是运行解析服务的用户或组,或者应该具有其他人设置的读取权限。