启用 NetworkManager 会导致 systemd-networkd-wait-online 失败

启用 NetworkManager 会导致 systemd-networkd-wait-online 失败

我刚刚开始进入 Ubuntu Server 的世界。

我开始编辑 netplan 以添加 NetworkManager 作为渲染器。*.yaml 文件如下所示

network:
  ethernets:
    eno1:
      dhcp4: true
  version: 2
  renderer: NetworkManager

如果我删除渲染器,systemd-networkd-wait-online.service就可以正常启动。

-- Boot f8c386c2c80b40b983635e474ef9129c --
Jan 17 22:06:11 server systemd[1]: Starting Wait for Network to be Configured...
Jan 17 22:06:16 server systemd[1]: Finished Wait for Network to be Configured.
Jan 18 08:10:17 server systemd[1]: systemd-networkd-wait-online.service: Deactivated successfully.
Jan 18 08:10:17 server systemd[1]: Stopped Wait for Network to be Configured.

但是当我添加渲染器时,此服务在等待时失败

-- Boot 03b42ba713bb4da4b5cf96600ae9f67f --
Jan 18 08:10:39 server systemd[1]: Starting Wait for Network to be Configured...
Jan 18 08:12:39 server systemd-networkd-wait-online[670]: Timeout occurred while waiting for network connectivity.
Jan 18 08:12:39 server systemd[1]: systemd-networkd-wait-online.service: Main process exited, code=exited, status=1/FAILURE
Jan 18 08:12:39 server systemd[1]: systemd-networkd-wait-online.service: Failed with result 'exit-code'.
Jan 18 08:12:39 server systemd[1]: Failed to start Wait for Network to be Configured.
Jan 18 08:23:08 server systemd[1]: Starting Wait for Network to be Configured...
Jan 18 08:25:08 server systemd-networkd-wait-online[5857]: Timeout occurred while waiting for network connectivity.
Jan 18 08:25:08 server systemd[1]: systemd-networkd-wait-online.service: Main process exited, code=exited, status=1/FAILURE
Jan 18 08:25:08 server systemd[1]: systemd-networkd-wait-online.service: Failed with result 'exit-code'.
Jan 18 08:25:08 server systemd[1]: Failed to start Wait for Network to be Configured.

有人可以指导我如何解决这个问题以及为什么会发生这种情况吗?

答案1

NetworkManager 和 systemd-networkd 一起运行时不兼容。它们执行相同的工作并尝试管理相同的资源,即网络。如果您在 systemd-networkd 中有一些配置,则应继续使用它,而不要切换。

否则,您需要systemd-networkd在启用 NetworkManager 之前禁用它。我假设您已经安装了软件包。现在您的目标是我在非服务器桌面 Ubuntu 安装上所拥有的:

$ networkctl
WARNING: systemd-networkd is not running, output will be incomplete.
[...]
$ systemctl status systemd-networkd
○ systemd-networkd.service - Network Configuration
     Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; preset: enabled)
     Active: inactive (dead)
[...]
$ systemctl status systemd-networkd-wait-online.service
○ systemd-networkd-wait-online.service - Wait for Network to be Configured
     Loaded: loaded (/lib/systemd/system/systemd-networkd-wait-online.service; disabled; preset: disabled)
     Active: inactive (dead)
       Docs: man:systemd-networkd-wait-online.service(8)

为了达到这个目的,你可以应用相反的方法https://askubuntu.com/a/1387807/1004020

sudo systemctl stop systemd-networkd
sudo systemctl disable systemd-networkd
sudo systemctl mask systemd-networkd

sudo systemctl stop systemd-networkd-wait-online.service
sudo systemctl disable systemd-networkd-wait-online.service
sudo systemctl mask systemd-networkd-wait-online.service

sudo systemctl unmask network-manager
sudo systemctl enable network-manager
sudo systemctl start network-manager

sudo mv /etc/systemd/network /etc/systemd/network.old
sudo mkdir /etc/systemd/network

基本上,禁用它很重要,system-networkd.service这样您就不会有两个网络管理器互相干扰。 的故障systemd-networkd-wait-online.service是无害且可以忽略的,我们在迁移到 NetworkManager 时只需禁用该服务即可。

完成此操作并重新启动后,一切都应由 NetworkManager 控制。同样,如果您的 Ubuntu Server 版本默认为 systemd-networkd,则教程、文档和支持可能不太适合 NetworkManager。您可能需要调整 netplan 配置并确保它仍然受尊重。

相关内容