Netplan 在 Ubuntu 20.04 服务器发行版上启动时不适用

Netplan 在 Ubuntu 20.04 服务器发行版上启动时不适用

每次开机后都netplan apply需要执行连接网络。

尝试了以下解决方案 https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/1879592/comments/3 https://askubuntu.com/a/1043349/1597089

如上所述这里,该问题已在最新的 Ubuntu 18.04 systemd-networkd 中修复。但该问题仍然存在于 Ubuntu 20.04 服务器发行版中。这是全新安装,我是 Linux 新手。

细节 :

  • 操作系统:Ubuntu 20.04 服务器

  • 无线上网:tplink WN725N

以下是命令的输出

journalctl -lu systemd-networkd

May 22 04:10:13 jra systemd[1]: Starting Network Service...
May 22 04:10:20 jra systemd-networkd[710]: Enumeration completed
May 22 04:10:20 jra systemd[1]: Started Network Service.
May 22 04:10:20 jra systemd-networkd[710]: wlxb4b024d25486: Interface name change detected, wlxb4b024d25486 has been renamed to wlan0.
May 22 04:10:20 jra systemd-networkd[710]: wlan0: Interface name change detected, wlan0 has been renamed to wlxb4b024d25486.
May 22 04:10:20 jra systemd-networkd[710]: wlxb4b024d25486: Link UP
May 22 04:10:20 jra systemd-networkd[710]: enp37s0: IPv6 successfully enabled
May 22 04:10:20 jra systemd-networkd[710]: wlxb4b024d25486: Failed
May 22 04:10:20 jra systemd-networkd[710]: enp37s0: Link UP
May 22 04:10:22 jra systemd-networkd[710]: wlxb4b024d25486: Gained carrier
May 22 04:10:22 jra systemd-networkd[710]: Could not process link message, ignoring: No such device
May 22 04:14:49 jra systemd[1]: Stopping Network Service...
May 22 04:14:49 jra systemd[1]: systemd-networkd.service: Succeeded.
May 22 04:14:49 jra systemd[1]: Stopped Network Service.

但每次重启后,netplan apply互联网就可以正常工作。

systemd-networkd 信息:

Package: systemd
Version: 245.4-4ubuntu3.17
Priority: important
Section: admin
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian systemd Maintainers <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 15.7 MB
Pre-Depends: libblkid1 (>= 2.24), libc6 (>= 2.30), libgcrypt20 (>= 1.8.0), liblz4-1 (>= 0.0~r122), liblzma5 (>= 5.1.1alpha+20120614), libselinux1 (>= 2.1.9)
Depends: libacl1 (>= 2.2.23), libapparmor1 (>= 2.9.0-3+exp2), libaudit1 (>= 1:2.2.1), libcap2 (>= 1:2.24-9~), libcrypt1 (>= 1:4.4.0), libcryptsetup12 (>= 2:2.0.1), libgnutls30 (>= 3.6.12), libgpg-error0 (>= 1.14), libidn2-0 (>= 2.0.0), libip4tc2 (>= 1.8.3), libkmod2 (>= 5~), liblz4-1 (>= 0.0~r130), libmount1 (>= 2.30), libpam0g (>= 0.99.7.1), libpcre2-8-0 (>= 10.22), libseccomp2 (>= 2.4.1), libsystemd0 (= 245.4-4ubuntu3.17), systemd-timesyncd | time-daemon, util-linux (>= 2.27.1), mount (>= 2.26), adduser
Recommends: dbus, networkd-dispatcher
Suggests: systemd-container, policykit-1
Conflicts: consolekit, libpam-ck-connector, systemd-shim, upstart
Breaks: python-dbusmock (<< 0.18), python3-dbusmock (<< 0.18), systemd-shim (<< 10-4~)
Homepage: https://www.freedesktop.org/wiki/Software/systemd
Task: minimal, ubuntu-core
Download-Size: 3,809 kB
APT-Manual-Installed: no
APT-Sources: http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
Description: system and service manager
 systemd is a system and service manager for Linux. It provides aggressive
 parallelization capabilities, uses socket and D-Bus activation for starting
 services, offers on-demand starting of daemons, keeps track of processes using
 Linux control groups, maintains mount and automount points and implements an
 elaborate transactional dependency-based service control logic.
 .
 systemd is compatible with SysV and LSB init scripts and can work as a
 drop-in replacement for sysvinit.
 .
 Installing the systemd package will not switch your init system unless you
 boot with init=/lib/systemd/systemd or install systemd-sysv in addition.

Netplan 状态:

 netplan-wpa-wlxb4b024d25486.service - WPA supplicant for netplan wlxb4b024d25486
     Loaded: loaded (/run/systemd/system/netplan-wpa-wlxb4b024d25486.service; enabled-runtime; vendor preset: enabled)
     Active: active (running) since Sun 2022-05-22 04:26:25 UTC; 1min 42s ago
   Main PID: 1357 (wpa_supplicant)
      Tasks: 1 (limit: 6922)
     Memory: 1.2M
     CGroup: /system.slice/netplan-wpa-wlxb4b024d25486.service
             └─1357 /sbin/wpa_supplicant -c /run/netplan/wpa-wlxb4b024d25486.conf -iwlxb4b024d25486 -Dnl80211,wext

May 22 04:26:25 jra wpa_supplicant[1357]: rfkill: Cannot get wiphy information
May 22 04:26:38 jra wpa_supplicant[1357]: ioctl[SIOCSIWAP]: Operation not permitted
May 22 04:26:38 jra wpa_supplicant[1357]: ioctl[SIOCSIWENCODEEXT]: Invalid argument
May 22 04:26:38 jra wpa_supplicant[1357]: ioctl[SIOCSIWENCODEEXT]: Invalid argument
May 22 04:26:40 jra wpa_supplicant[1357]: wlxb4b024d25486: Trying to associate with f8:1c:18:5c:73:d5 (SSID='JRM' freq=2437 MHz)
May 22 04:26:40 jra wpa_supplicant[1357]: Failed to add supported operating classes IE
May 22 04:26:40 jra wpa_supplicant[1357]: wlxb4b024d25486: Association request to the driver failed
May 22 04:26:41 jra wpa_supplicant[1357]: wlxb4b024d25486: Associated with f8:1c:18:5c:73:d5
May 22 04:26:41 jra wpa_supplicant[1357]: wlxb4b024d25486: WPA: Key negotiation completed with f8:1c:18:5c:73:d5 [PTK=CCMP GTK=TKIP]
May 22 04:26:41 jra wpa_supplicant[1357]: wlxb4b024d25486: CTRL-EVENT-CONNECTED - Connection to f8:1c:18:5c:73:d5 completed [id=0 id_str=]

Netplan 说连接完成并且没有任何问题但是没有互联网并且 ping 8.8.8.8 说网络无法访问。

Netplan YAML:

sudo ls /etc/netplan/
00-installer-config-wifi.yaml  00-installer-config.yaml

00-安装程序-配置-wifi.yaml:

network:
  version: 2
  wifis:
    wlxb4b024d25486:
      optional: true
      access-points:
         "SSID":
             password: "password"
      dhcp4: true
      macaddress: "my USB WiFi Adaptor mac"

00-安装程序-config.yaml:

network:
  ethernets:
    enp37s0:
      optional: true
      dhcp4: true
  version: 2

相关内容