当渲染器联网时,netplan 正在尝试重新启动 NetworkManager

当渲染器联网时,netplan 正在尝试重新启动 NetworkManager

我熟悉旧式接口配置,但不熟悉 netplan。这是 Raspberry Pi 4 上的 Ubuntu Server 20.04 LTS。

我正在尝试配置一个静态 IP 地址,因此我按照在线示例进行操作,并且愚蠢地尝试使用 NetworkManager 作为渲染器(因为我复制/粘贴了)。 sudo netplan try正确地告诉我:Failed to start NetworkManager.service: Unit NetworkManager.service not found。我真傻。

所以我返回/etc/netplan/01-network-manager-all.yaml并将渲染器更改为 networkd。然后我运行sudo netplan try并再次得到:Failed to start NetworkManager.service: Unit NetworkManager.service not found。什么?

看一下这个:

$ ls /etc/netplan/
total 12K
drwxr-xr-x  2 root root 4.0K Jan 24 20:33 ./
drwxr-xr-x 93 root root 4.0K Jan 24 19:31 ../
-rw-r--r--  1 root root  226 Jan 24 20:31 01-network-manager-all.yaml

$ cat /etc/netplan/01-network-manager-all.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: false
      addresses:
      - 10.11.12.15/24
      nameservers:
        addresses:
        - 8.8.8.8
        - 8.8.4.4
      gateway4: 10.11.12.1

$ sudo netplan try
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket
Failed to start NetworkManager.service: Unit NetworkManager.service not found.

An error occurred: Command '['systemctl', 'start', 'NetworkManager.service']' returned non-zero exit status 5.

Reverting.
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket
Failed to start NetworkManager.service: Unit NetworkManager.service not found.
Traceback (most recent call last):
  File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 83, in command_try
    NetplanApply.command_apply(run_generate=True, sync=True, exit_on_error=False)
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 181, in command_apply
    utils.systemctl_network_manager('start', sync=sync)
  File "/usr/share/netplan/netplan/cli/utils.py", line 72, in systemctl_network_manager
    subprocess.check_call(command)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'start', 'NetworkManager.service']' returned non-zero exit status 5.

当我将渲染器更改为网络时,为什么 netplan 仍尝试重新启动 NetworkManager?

答案1

遇到了同样的问题,意识到仅仅编辑 yaml 文件显然是不够的,您还必须运行:

sudo netplan generate && sudo netplan try

希望这对你也有用!

相关内容