NetworkManager가 AP를 전환할 수 없음: 연결 활성화 실패

NetworkManager가 AP를 전환할 수 없음: 연결 활성화 실패

일부 외부 로직을 기반으로 IoT 장치가 연결된 AP를 전환하고 싶습니다. 내 AP 전환 스크립트는 다음과 같습니다.

function switch_ap() {
  current_connection=$(nmcli conn show --active | tail -n 1 | cut -d' ' -f1)
  nmcli conn down $current_connection
  if test "$current_connection" = "home_ap"; then
    nmcli conn up iot_ap
  else
    nmcli conn up home_ap
  fi
  new_connection=$(nmcli conn show --active | tail -n 1 | cut -d' ' -f1)
  echo "was connected to $current_connection, now connected to connection: $(nmcli conn show --active | tail -n 1 | cut -d' ' -f1) ssid: $(iwgetid wlan0 -r)"
}

이것은 때때로 작동하지만 신뢰할 수 없습니다. 종종 오류가 발생합니다.

Connection 'home_ap' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/66)
Error: Connection activation failed: The base network connection was interrupted
Hint: use 'journalctl -xe NM_CONNECTION=dcbf7f18-1e26-41bb-a874-c1ce6718dbf2 + NM_DEVICE=wlan0' to get more details.

명령을 실행하는 데 문제 는 없지만 journalctl다른 사람이 이 로그를 더 잘 구문 분석할 수 있도록 이 게시물 하단에 출력을 공유하겠습니다.

내 해킹 수정은 다음 기능입니다.

function switch_ap() {
  current_connection=$(nmcli conn show --active | tail -n 1 | cut -d' ' -f1)
  nmcli conn down $current_connection
  if test "$current_connection" = "home_ap"; then
    mv /etc/nm_connections/iot_ap.nmconnection /opt/nm_connections/
    mv /opt/home_ap.nmconnection /etc/nm_connections/
    nmcli conn up iot_ap
  else
    mv /etc/nm_connections/home_ap.nmconnection /opt/nm_connections/
    mv /opt/nm_connections/iot_ap.nmconnection /etc/nm_connections/
    nmcli conn up home_ap
  fi
  new_connection=$(nmcli conn show --active | tail -n 1 | cut -d' ' -f1)
  echo "was connected to $current_connection, now connected to connection: $(nmcli conn show --active | tail -n 1 | cut -d' ' -f1) ssid: $(iwgetid wlan0 -r)"
}

이것은 안정적으로 작동하는 것 같지만 이제 연결된 앱에 대한 연결이 끊어지면 자동으로 전환되지 않습니다. 이는 일종의 해킹입니다. 또한 이제 이러한 경고가 더 자주 표시됩니다.

(process:12734): GLib-GIO-WARNING **: 06:05:20.284: ../../gio/gdbusobjectmanagerclient.c:1589: Processing InterfaceRemoved signal for path /org/freedesktop/NetworkManager/IP4Config/35 but no object proxy exists

(process:12734): GLib-GIO-WARNING **: 06:05:20.293: ../../gio/gdbusobjectmanagerclient.c:1589: Processing InterfaceRemoved signal for path /org/freedesktop/NetworkManager/IP6Config/35 but no object proxy exists

(process:12734): GLib-GIO-WARNING **: 06:05:20.591: ../../gio/gdbusobjectmanagerclient.c:1589: Processing InterfaceRemoved signal for path /org/freedesktop/NetworkManager/ActiveConnection/35 but no object proxy exists

내 AP 스위칭을 더욱 안정적으로 만들 수 있는 방법이 있나요?

다음은 명령의 로그입니다 journalctl.

Connection 'iot_ap' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/33)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/37)
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.5536] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.5912] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.5946] device (wlan0): Activation: (wifi) access point 'home_ap' has security, but secrets are required.
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.5948] device (wlan0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.6554] device (wlan0): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.6598] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.6634] device (wlan0): Activation: (wifi) connection 'home_ap' has security, and secrets exist.  No new secrets needed.
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.9623] device (wlan0): disconnecting for new activation request.
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.9626] device (wlan0): state change: config -> deactivating (reason 'new-activation', sys-iface-state: 'managed')
Apr 21 09:03:08 DEVICE-072059 NetworkManager[249]: <info>  [1587481388.9781] device (wlan0): state change: deactivating -> disconnected (reason 'new-activation', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.0102] device (wlan0): Activation: starting connection 'iot_ap' (b109024a-84b9-46b7-a810-2d2472676c7f)
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.0413] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.0750] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.0810] device (wlan0): Activation: (wifi) access point 'iot_ap' has security, but secrets are required.
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.0819] device (wlan0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.0867] sup-iface[0x3a2201c0,wlan0]: wps: type pbc start...
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.8388] device (wlan0): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.8922] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.9060] device (wlan0): Activation: (wifi) connection 'iot_ap' has security, and secrets exist.  No new secrets needed.
Apr 21 09:03:09 DEVICE-072059 NetworkManager[249]: <info>  [1587481389.9470] device (wlan0): supplicant interface state: disconnected -> inactive
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.4927] device (wlan0): supplicant interface state: inactive -> associating
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.5582] device (wlan0): disconnecting for new activation request.
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.5584] device (wlan0): state change: config -> deactivating (reason 'new-activation', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.5645] device (wlan0): state change: deactivating -> disconnected (reason 'new-activation', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.5915] device (wlan0): Activation: starting connection 'home_ap' (dcbf7f18-1e26-41bb-a874-c1ce6718dbf2)
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.6027] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.6214] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.6386] device (wlan0): Activation: (wifi) access point 'home_ap' has security, but secrets are required.
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.6388] device (wlan0): state change: config -> need-auth (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <warn>  [1587481390.6968] sup-iface[0x3a2201c0,wlan0]: connection disconnected (reason -3)
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.6974] device (wlan0): supplicant interface state: associating -> disconnected
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.6983] device (wlan0): state change: need-auth -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.7046] device (wlan0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.7357] device (wlan0): Activation: (wifi) connection 'home_ap' has security, and secrets exist.  No new secrets needed.
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <info>  [1587481390.7815] device (wlan0): supplicant interface state: disconnected -> associated
Apr 21 09:03:10 DEVICE-072059 NetworkManager[249]: <warn>  [1587481390.7900] sup-iface[0x3a2201c0,wlan0]: connection disconnected (reason -3)
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info>  [1587481391.0013] device (wlan0): supplicant interface state: associated -> disconnected
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info>  [1587481391.6999] device (wlan0): supplicant interface state: disconnected -> associating
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info>  [1587481391.7886] device (wlan0): supplicant interface state: associating -> 4-way handshake
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info>  [1587481391.8417] device (wlan0): supplicant interface state: 4-way handshake -> completed
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info>  [1587481391.8419] device (wlan0): Activation: (wifi) Stage 2 of 5 (Device Configure) successful. Connected to wireless network "TheHome"
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info>  [1587481391.8624] device (wlan0): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info>  [1587481391.8689] dhcp4 (wlan0): activation: beginning transaction (timeout in 45 seconds)
Apr 21 09:03:11 DEVICE-072059 NetworkManager[249]: <info>  [1587481391.8964] dhcp4 (wlan0): dhclient started with pid 22677
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.2540] dhcp4 (wlan0):   address 192.168.1.61
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.2542] dhcp4 (wlan0):   plen 24 (255.255.255.0)
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.2543] dhcp4 (wlan0):   gateway 192.168.1.1
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.2546] dhcp4 (wlan0):   lease time 10806
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.2547] dhcp4 (wlan0):   nameserver '75.75.75.75'
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.2548] dhcp4 (wlan0):   nameserver '75.75.76.76'
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.2550] dhcp4 (wlan0): state changed unknown -> bound
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.2964] device (wlan0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.3029] device (wlan0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.3051] device (wlan0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Apr 21 09:03:12 DEVICE-072059 NetworkManager[249]: <info>  [1587481392.4438] device (wlan0): Activation: successful, device activated.

답변1

네트워크 관리자는 네트워크를 관리하는 데 사용되며 가용성에 따라 네트워크를 전환하는 논리를 가지고 있습니다. 첫 번째 스크립트를 실행하고 제거하면 네트워크 관리자 데몬이 사용 가능한 기본값을 인식하고 연결할 수 있습니다.

두 번째는 네트워크 관리자에게 연결해야 하는 Wi-Fi 액세스 포인트를 알려주는 파일을 이동하는 것입니다. 따라서 홈 파일이 있으면 홈 디렉토리에만 연결할 수 있습니다. 홈 디렉토리가 홈 디렉토리에 대해 알고 있는 유일한 네트워크이기 때문입니다. iot 파일이 있는 경우에만 iot에 연결할 수 있습니다.

네트워크 관리자는 다른 네트워크가 존재하는지 모르기 때문에 전환되지 않습니다. 문제를 해결하는 가장 좋은 방법은 네트워크 관리자에서 SSID 우선순위를 설정하거나, 전원을 끄지 않고도 다른 SSID에 연결할 수 있는 "nmcli device wifi connect"를 사용하는 것입니다. 이 명령이 없으면 nmcli 매뉴얼 페이지를 참조하여 수행 방법을 알아보세요.

관련 정보