安装 systemd-resolved 会终止 dns 查找

安装 systemd-resolved 会终止 dns 查找

更新 卸载并重新安装后systemd-resolved,问题似乎已自行解决。我不明白为什么,但我确实注意到第二次/etc/resolv.conf安装后没有被修改,而第一次安装该软件包时它被修改了。systemd-resolved

问题:

我正在尝试遵循家庭助理监督安装程序说明这里在我的 Orange Pi Zero 上运行 Debian。这是从网络启动映像设置的。安装该systemd-resolved软件包后,系统无法再查找网站地址。卸载该软件包可以解决该问题。这是错误:

Temporary failure resolving 'deb.debian.org'

观察结果:

当我的设备使用 Armbian 映像时,这种情况并未发生,但 Home-Assistant 不支持 Armbian,因此我尝试使用 Debian。

我无法 ping 通网址(或网络上的 .locals),但可以 ping 通 IP 地址。

工作与预期工作:

预期(安装前工作systemd-resolved

jodie@orangePiZero:~$ wget -O homeassistant-supervised.deb https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
--2023-11-22 00:00:49--  https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
Resolving github.com (github.com)... 20.87.245.0
Connecting to github.com (github.com)|20.87.245.0|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github.com/home-assistant/supervised-installer/releases/download/1.5.0/homeassistant-supervised.deb [following]
--2023-11-22 00:00:50--  https://github.com/home-assistant/supervised-installer/releases/download/1.5.0/homeassistant-supervised.deb
Reusing existing connection to github.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/183216119/905cc380-f350-4a95-ac33-a2749b7858fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20231121%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231121T220050Z&X-Amz-Expires=300&X-Amz-Signature=21a10eb8987bbe62d3a2826be9ba66ed9476dbbe6015990ad0fb53b46db6224f&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=183216119&response-content-disposition=attachment%3B%20filename%3Dhomeassistant-supervised.deb&response-content-type=application%2Foctet-stream [following]
--2023-11-22 00:00:50--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/183216119/905cc380-f350-4a95-ac33-a2749b7858fa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20231121%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231121T220050Z&X-Amz-Expires=300&X-Amz-Signature=21a10eb8987bbe62d3a2826be9ba66ed9476dbbe6015990ad0fb53b46db6224f&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=183216119&response-content-disposition=attachment%3B%20filename%3Dhomeassistant-supervised.deb&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6504 (6.4K) [application/octet-stream]
Saving to: ‘homeassistant-supervised.deb’

homeassistant-supervised.d 100%[=======================================>]   6.35K  --.-KB/s    in 0.002s

2023-11-22 00:00:51 (2.50 MB/s) - ‘homeassistant-supervised.deb’ saved [6504/6504]

不工作:

jodie@orangePiZero:~$ wget -O homeassistant-supervised.deb https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
--2023-11-22 17:11:35--  https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
Resolving github.com (github.com)... failed: Temporary failure in name resolution.
wget: unable to resolve host address ‘github.com’

网络设置:

我有一个 tp-link 家用路由器,设置了该设备 MAC 地址的 DHCP 地址保留。它与我的其他设备位于同一子网中,并且未指定不同的 DNS 服务器。我仍然可以 ssh 进入设备(这就是我主要设置它的方式)

问题:

我需要设置 DNS 才能使用的配置吗systemd-resolved

请求的信息:

/etc/resolv.conf安装前的内容systemd-resolved

nameserver 192.168.0.1
nameserver 0.0.0.0

首次安装后的内容:

# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search .

卸载并重新安装后的内容:

nameserver 192.168.0.1
nameserver 0.0.0.0

/etc/nsswitch.conf安装前的内容systemd-resolved

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         files systemd
group:          files systemd
shadow:         files systemd
gshadow:        files systemd

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

首次安装后的内容systemd-resolved

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         files systemd
group:          files systemd
shadow:         files systemd
gshadow:        files systemd

hosts:          files resolve [!UNAVAIL=return] dns myhostname
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

卸载并重新安装后的内容systemd-resolved

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         files systemd
group:          files systemd
shadow:         files systemd
gshadow:        files systemd

hosts:          files resolve [!UNAVAIL=return] dns myhostname
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

其他信息

这是运行的结果resolvectl status

jodie@orangePiZero:~$ resolvectl status
Failed to get global data: Connection timed out

这是以下的输出systemctl status systemd-resolved

jodie@orangePiZero:~$ systemctl status systemd-resolved
● systemd-resolved.service - Network Name Resolution
     Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; preset: enabled)
     Active: active (running) since Tue 2023-11-21 23:09:21 SAST; 24min 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: 577 (systemd-resolve)
     Status: "Processing requests..."
      Tasks: 1 (limit: 1075)
     Memory: 2.3M
        CPU: 847ms
     CGroup: /system.slice/systemd-resolved.service
             └─577 /lib/systemd/systemd-resolved

答案1

似乎 systemd-resolved 以某种方式将network-manager的设置设置为手动,但保留了正确的 IP 地址。要解决此问题,您可以nmtui从终端运行(网络管理器终端用户界面)并将网络设置设置回自动(dhcp)。

在我安装 Home Assistant Supervisor 并正确运行后,设置由 Home Assistant Supervisor 管理。

相关内容