除非用户先登录,否则 NetworkManager 不会启动

除非用户先登录,否则 NetworkManager 不会启动

我在虚拟机中安装了 Ubuntu 20.10,带有 GNOME,并且已经与 NetworkManager 一起使用了一段时间。

juan@box:~$ uname -a
Linux box 5.8.0-26-generic #27-Ubuntu SMP Wed Oct 21 22:29:16 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
juan@box:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.10 (Groovy Gorilla)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.10"
VERSION_ID="20.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=groovy
UBUNTU_CODENAME=groovy
juan@box:~$

有时我必须在禁用 GUI 的情况下工作。每次我这样做时,我都会注意到虚拟机中的网络已停止,除非我先登录控制台(在我的情况下是 VMWare Fusion)。服务器无法 ping 通,SSH 失败(连接超时)。登录控制台后,ping 将立即起作用。

可以通过重新启动虚拟机、从主机运行连续 ping、登录控制台来轻松复制,并且在一秒钟内 ping 就会开始工作。

我计算了时间并发现了以下内容syslog

Nov  3 19:41:18 box NetworkManager[1310]: <info>  [1604428878.1898] device (ens38): state change: activated -> deactivating (reason 'connection-removed', sys-iface-state: 'managed')
Nov  3 19:41:18 box dbus-daemon[1182]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.10' (uid=0 pid=1310 comm="/usr/sbin/NetworkManager --no-daemon " label="unconfined")
Nov  3 19:41:18 box NetworkManager[1310]: <info>  [1604428878.2087] device (ens38): state change: deactivating -> disconnected (reason 'connection-removed', sys-iface-state: 'managed')

我最好的猜测是它与 GNOME 和 NetworkManager 有关。听起来好像他们在等待初始用户先登录 GUI 登录管理器,然后再启动网络服务。

提前谢谢您!

附言:如果这听起来微不足道,请原谅,但我已经很久没有接触过 GUI 了。

PPS:我知道我可以禁用并替换 NetworkManager,但是现在我想坚持使用“桌面上的 Linux”的一切。

答案1

找到了:

nmcli> describe connection.autoconnect

=== [autoconnect] ===
[NM property description]
Whether or not the connection should be automatically connected by
NetworkManager when the resources for the connection are available.
TRUE to automatically activate the connection,
FALSE to require manual intervention to activate the connection.

Note that autoconnect is not implemented for VPN profiles.
See "secondaries" as an alternative to automatically connect VPN profiles.


nmcli>

相关内容