Network Managerの自動接続が常に機能するわけではありません。

Network Managerの自動接続が常に機能するわけではありません。

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プロトコルを無効にしました!

2番目であり、さらに重要なのは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 ''

関連情報