Wifi 网络连接不断断开。需要重新启动 NetworkManager 才能正常工作

Wifi 网络连接不断断开。需要重新启动 NetworkManager 才能正常工作

我的 WiFi 网络连接有问题。尽管我仍连接到网络,但总是断线。每次发生这种情况时,我都会输入以下命令:

sudo systemctl restart NetworkManager

然后我的互联网连接恢复了。

我将在下面发布我的驱动程序版本和其他信息,希望有人能够帮助我解决这个问题。

bukojuice@Ubuntu-xps:~$ uname -r 
5.0.0-31-generic
bukojuice@Ubuntu-xps:~$ sudo lshw -C network
*-network  
description: Wireless interface
product: AR9485 Wireless Network Adapter
vendor: Qualcomm Atheros
physical id: 0
bus info: pci@0000:0c:00.0
logical name: wlp12s0
version: 01
serial:
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list rom ethernet physical wireless
configuration: broadcast=yes driver=ath9k driverversion=5.0.0-31-generic firmware=N/A ip= latency=0 link=yes multicast=yes wireless=IEEE 802.11
resources: irq:17 memory:f6880000-f68fffff memory:f6900000-f690fff 

你好,我发现一个错误journalctl -b 0 /usr/sbin/NetworkManager

Oct 16 08:47:54 Ubuntu-xps NetworkManager[18018]: <warn> [1571186874.0452] sup-iface[0x557cc3bcb230,wlp12s0]: connection disconnected (reason -4) 
Oct 16 08:47:54 Ubuntu-xps NetworkManager[18018]: <info> [1571186874.0693] device (wlp12s0):supplicant interface state: completed -> disconnected 
Oct 16 08:47:54 Ubuntu-xps NetworkManager[18018]: <info> [1571186874.1633] device (wlp12s0): supplicant interface state: disconnected -> scanning 
Oct 16 08:48:01 Ubuntu-xps NetworkManager[18018]: <info> [1571186881.3148] device (wlp12s0): supplicant interface state: scanning -> authenticating 
Oct 16 08:48:01 Ubuntu-xps NetworkManager[18018]: <info>  [1571186881.3355] device (wlp12s0): supplicant interface state: authenticating -> associated 
Oct 16 08:48:01 Ubuntu-xps NetworkManager[18018]: <info>  [1571186881.4357] device (wlp12s0): supplicant interface state: associated -> 4-way handshake 
Oct 16 08:48:01 Ubuntu-xps NetworkManager[18018]: <info>  [1571186881.4421] device (wlp12s0): supplicant interface state: 4-way handshake -> completed 
Oct 16 08:50:58 Ubuntu-xps NetworkManager[18018]: <info> [1571187058.7186] caught SIGTERM, shutting down normally. 
Oct 16 08:50:58 Ubuntu-xps NetworkManager[18018]: <info>  [1571187058.7248] device (wlp12s0): state change: activated -> deactivating (reason'unmanage 
Oct 16 08:50:58 Ubuntu-xps NetworkManager[18018]: <info> [1571187058.7252] manager: NetworkManager state is now DISCONNECTING
Oct 16 08:50:58 Ubuntu-xps NetworkManager[18018]: <info> [1571187058.7794] device (wlp12s0): state change: deactivating -> unmanaged (reason 'removed' 
Oct 16 08:50:59 Ubuntu-xps NetworkManager[18018]: <info>  [1571187059.2326] manager: NetworkManager state is now DISCONNECTED 
Oct 16 08:50:59 Ubuntu-xps NetworkManager[18018]: <info>  [1571187059.2745] exiting (success)

答案1

您可以使用这个答案的一部分:

创建此脚本:

#!/bin/sh

# NAME: /lib/systemd/system-sleep/network-reset
# DESC: Resets network manager after a suspend.
# DATE: December 14, 2019.

MYNAME=$0

restart_wifi() {
    /usr/bin/logger $MYNAME 'restart_wifi BEGIN'
    systemctl restart NetworkManager.service
    /usr/bin/logger $MYNAME 'restart_wifi END'
}

/usr/bin/logger $MYNAME 'case=[' ${1}' ]'
case "${1}/${2}" in
    hibernate|suspend|pre*)
      ;;
    resume|thaw|post*)
      restart_wifi;;
esac

使用以下命令使脚本可执行:

sudo chmod a+x /lib/systemd/system-sleep/network-reset

笔记:这个答案解决了问题的影响,但并没有解决问题的根源。

相关内容