在 RPi 3 B+ 的 Buildroot 环境中,我有以下连接文件:
# cat /etc/NetworkManager/system-connections/mark.nmconnection
[connection]
id=mark
uuid=0f285419-2238-4b94-ad48-577a1a5f3765
type=wifi
interface-name=wlan0
timestamp=295
autoconnect=true
[wifi]
mode=infrastructure
ssid=mark
[wifi-security]
key-mgmt=wpa-psk
psk=mypassword
[ipv4]
dns=192.168.2.1;8.8.8.8;
method=auto
[ipv6]
addr-gen-mode=default
method=disabled
有问题:当连接建立时,第一个问题出现在控制台上,我读到:
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: 链路准备就绪
但我已经禁用了 ipv6 协议!
第二个也是更重要的是autoconnect
行为。
这里我读到默认值是true
但在我的文件中没有这个选项绝不自动连接。我总是需要发出:
# nmcli con up mark
相反,添加autoconnect=true
会导致奇怪的行为。有时它会自动连接,其他则不会。接入点很近并且始终处于活动状态。事实上,当它没有自动连接时,发出上述命令会导致立即连接。
我检查了日志(/var/logs/messages
)。当它没有连接时,最后的消息是:
Jan 1 00:00:08 mark daemon.info NetworkManager[267]: <info> [8.9299] NetworkManager (version 1.42.0) is starting... (boot:a02ac8dc-0c02-4a96-a3f4-2615029efee6)
Jan 1 00:00:08 mark daemon.info NetworkManager[267]: <info> [8.9302] Read config: /etc/NetworkManager/NetworkManager.conf
Jan 1 00:00:08 mark daemon.info NetworkManager[267]: <info> [8.9521] bus-manager: acquired D-Bus service "org.freedesktop.NetworkManager"
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0134] manager[0x55bd54ed10]: monitoring kernel firmware directory '/lib/firmware'.
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0322] hostname: hostname: couldn't get property from hostnamed
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0338] hostname: static hostname changed from (none) to "mark"
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0374] dns-mgr: init: dns=default,systemd-resolved rc-manager=file
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0419] rfkill0: found Wi-Fi radio killswitch (at /sys/devices/platform/soc/3f300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1/ieee80211/phy0/rfkill0) (driver brcmfmac)
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0431] manager[0x55bd54ed10]: rfkill: Wi-Fi hardware radio set enabled
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0433] manager[0x55bd54ed10]: rfkill: WWAN hardware radio set enabled
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0619] Loaded device plugin: NMAtmManager (/usr/lib/NetworkManager/1.42.0/libnm-device-plugin-adsl.so)
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0727] Loaded device plugin: NMWifiFactory (/usr/lib/NetworkManager/1.42.0/libnm-device-plugin-wifi.so)
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0734] manager: rfkill: Wi-Fi enabled by radio killswitch; enabled by state file
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0741] manager: rfkill: WWAN enabled by radio killswitch; enabled by state file
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0745] manager: Networking is enabled by state file
Jan 1 00:00:09 mark daemon.info dbus-daemon[256]: [system] Activating service name='org.freedesktop.nm_dispatcher' requested by ':1.0' (uid=0 pid=267 comm="/usr/sbin/NetworkManager") (using servicehelper)
Jan 1 00:00:09 mark daemon.warn NetworkManager[267]: <warn> [9.0871] settings: could not load plugin 'ifupdown' from file '/usr/lib/NetworkManager/1.42.0/libnm-settings-plugin-ifupdown.so': No such file or directory
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.0875] settings: Loaded settings plugin: keyfile (internal)
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.1254] dhcp: init: Using DHCP client 'internal'
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.1284] manager: (lo): new Loopback device (/org/freedesktop/NetworkManager/Devices/1)
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.1404] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/2)
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.1519] settings: (eth0): created default wired connection 'Wired connection 1'
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.1523] device (eth0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Jan 1 00:00:09 mark daemon.info dbus-daemon[256]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.2498] device (wlan0): driver supports Access Point (AP) mode
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.2572] manager: (wlan0): new 802.11 Wi-Fi device (/org/freedesktop/NetworkManager/Devices/3)
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.2602] device (wlan0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Jan 1 00:00:09 mark kern.info kernel: [ 9.291489] NET: Registered protocol family 10
Jan 1 00:00:09 mark kern.info kernel: [ 9.301271] brcmfmac: brcmf_cfg80211_set_power_mgmt: power save enabled
Jan 1 00:00:09 mark kern.info kernel: [ 9.320675] Segment Routing with IPv6
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.8872] device (wlan0): set-hw-addr: set MAC address to 92:89:66:51:06:EF (scanning)
Jan 1 00:00:09 mark kern.info kernel: [ 9.891675] brcmfmac: brcmf_cfg80211_set_power_mgmt: power save enabled
Jan 1 00:00:09 mark daemon.info dbus-daemon[256]: [system] Activating service name='fi.w1.wpa_supplicant1' requested by ':1.0' (uid=0 pid=267 comm="/usr/sbin/NetworkManager") (using servicehelper)
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9390] device (lo): state change: unmanaged -> unavailable (reason 'connection-assumed', sys-iface-state: 'external')
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9444] device (lo): state change: unavailable -> disconnected (reason 'connection-assumed', sys-iface-state: 'external')
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9511] device (lo): Activation: starting connection 'lo' (14489a2d-6709-4e4f-b28b-e924fcb0bc95)
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9519] device (lo): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'external')
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9545] device (lo): state change: prepare -> config (reason 'none', sys-iface-state: 'external')
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9566] device (lo): state change: config -> ip-config (reason 'none', sys-iface-state: 'external')
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9587] device (lo): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'external')
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9766] device (lo): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'external')
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9784] device (lo): state change: secondaries -> activated (reason 'none', sys-iface-state: 'external')
Jan 1 00:00:09 mark daemon.info NetworkManager[267]: <info> [9.9833] device (lo): Activation: successful, device activated.
Jan 1 00:00:10 mark daemon.info dbus-daemon[256]: [system] Successfully activated service 'fi.w1.wpa_supplicant1'
Jan 1 00:00:10 mark daemon.info NetworkManager[267]: <info> [10.4979] device (wlan0): supplicant interface state: internal-starting -> disconnected
Jan 1 00:00:10 mark daemon.info NetworkManager[267]: <info> [10.4987] Wi-Fi P2P device controlled by interface wlan0 created
Jan 1 00:00:10 mark daemon.info NetworkManager[267]: <info> [10.5021] manager: (p2p-dev-wlan0): new 802.11 Wi-Fi P2P device (/org/freedesktop/NetworkManager/Devices/4)
Jan 1 00:00:10 mark daemon.info NetworkManager[267]: <info> [10.5043] device (p2p-dev-wlan0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Jan 1 00:00:10 mark daemon.info NetworkManager[267]: <info> [10.5083] device (wlan0): state change: unavailable -> disconnected (reason 'supplicant-available', sys-iface-state: 'managed')
Jan 1 00:00:10 mark daemon.info NetworkManager[267]: <info> [10.5159] device (p2p-dev-wlan0): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
Jan 1 00:00:10 mark auth.info sshd[296]: Server listening on 0.0.0.0 port 22.
Jan 1 00:00:10 mark auth.info sshd[296]: Server listening on :: port 22.
Jan 1 00:00:13 mark daemon.info : starting pid 484, tty '/dev/console': '/sbin/getty -L console 0 vt100 '
Jan 1 00:00:13 mark daemon.info : starting pid 485, tty '/dev/tty1': '-/bin/sh'
Jan 1 00:00:15 mark daemon.info NetworkManager[267]: <info> [15.1762] manager: startup complete
相反,当它工作正常时,它startup complete
会继续:
Jan 1 00:00:20 mark daemon.info NetworkManager[267]: <info> [20.9056] policy: auto-activating connection 'mark' (0f285419-2238-4b94-ad48-577a1a5f3765)
Jan 1 00:00:20 mark daemon.info NetworkManager[267]: <info> [20.9093] device (wlan0): Activation: starting connection 'mark' (0f285419-2238-4b94-ad48-577a1a5f3765)
Jan 1 00:00:20 mark daemon.info NetworkManager[267]: <info> [20.9100] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Jan 1 00:00:20 mark daemon.info NetworkManager[267]: <info> [20.9124] manager: NetworkManager state is now CONNECTING
Jan
...
我的连接文件有问题吗?
答案1
连接可以拥有用户的权限。然后,仅当特定用户登录时才开始连接。您可以使用以下命令查看权限
nmcli connection show CONNECTIONNAME
您可以使用以下命令清除权限
nmcli connection modify CONNECTIONNAME -connection.permissions ''