使用 NetworkManager 时 WiFi 断开-重新连接循环

使用 NetworkManager 时 WiFi 断开-重新连接循环

正如标题所述,当我使用桌面 GUI 工具连接 WiFi 时,我的 WiFi 每隔几分钟就会断开并重新连接。

以下是来自 syslog 的部分输出dmesg

[ 4057.718731] wlan0: deauthenticating from xx:xx:xx:xx:fa:80 by local choice (Reason: 2=PREV_AUTH_NOT_VALID)
[ 4063.163118] wlan0: authenticate with xx:xx:xx:xx:fa:80
[ 4063.215966] wlan0: send auth to xx:xx:xx:xx:fa:80 (try 1/3)
[ 4063.218028] wlan0: authenticated
[ 4063.227742] wlan0: associate with xx:xx:xx:xx:fa:80 (try 1/3)
[ 4063.231665] wlan0: RX AssocResp from xx:xx:xx:xx:fa:80 (capab=0x411 status=0 aid=4)
[ 4063.235835] wlan0: associated
[ 4063.236153] ath: EEPROM regdomain: 0x8348
[ 4063.236165] ath: EEPROM indicates we should expect a country code
[ 4063.236173] ath: doing EEPROM country->regdmn map search
[ 4063.236178] ath: country maps to regdmn code: 0x3a
[ 4063.236183] ath: Country alpha2 being used: US
[ 4063.236188] ath: Regpair used: 0x3a
[ 4063.236193] ath: regdomain 0x8348 dynamically updated by country element
[ 4140.174715] wlan0: deauthenticating from xx:xx:xx:xx:fa:80 by local choice (Reason: 2=PREV_AUTH_NOT_VALID)
[ 4145.654878] wlan0: authenticate with xx:xx:xx:xx:fa:80
[ 4145.707746] wlan0: send auth to xx:xx:xx:xx:fa:80 (try 1/3)
[ 4145.711686] wlan0: authenticated
[ 4145.717005] wlan0: associate with xx:xx:xx:xx:fa:80 (try 1/3)
[ 4145.720996] wlan0: RX AssocResp from xx:xx:xx:xx:fa:80 (capab=0x411 status=0 aid=3)
[ 4145.726610] wlan0: associated
[ 4145.726950] ath: EEPROM regdomain: 0x8348
[ 4145.726963] ath: EEPROM indicates we should expect a country code
[ 4145.726969] ath: doing EEPROM country->regdmn map search
[ 4145.726973] ath: country maps to regdmn code: 0x3a
[ 4145.726977] ath: Country alpha2 being used: US
[ 4145.726980] ath: Regpair used: 0x3a
[ 4145.726984] ath: regdomain 0x8348 dynamically updated by country element
[ 4221.796363] wlan0: deauthenticating from xx:xx:xx:xx:fa:80 by local choice (Reason: 2=PREV_AUTH_NOT_VALID)
[ 4227.236738] wlan0: authenticate with xx:xx:xx:xx:fa:80
[ 4227.288859] wlan0: send auth to xx:xx:xx:xx:fa:80 (try 1/3)
[ 4227.291345] wlan0: authenticated
[ 4227.299135] wlan0: associate with xx:xx:xx:xx:fa:80 (try 1/3)
[ 4227.307388] wlan0: RX AssocResp from xx:xx:xx:xx:fa:80 (capab=0x411 status=0 aid=3)
[ 4227.311607] wlan0: associated
[ 4227.312000] ath: EEPROM regdomain: 0x8348
[ 4227.312014] ath: EEPROM indicates we should expect a country code
[ 4227.312022] ath: doing EEPROM country->regdmn map search
[ 4227.312028] ath: country maps to regdmn code: 0x3a
[ 4227.312033] ath: Country alpha2 being used: US
[ 4227.312038] ath: Regpair used: 0x3a
[ 4227.312043] ath: regdomain 0x8348 dynamically updated by country element
[ 4314.140165] wlan0: deauthenticating from xx:xx:xx:xx:fa:80 by local choice (Reason: 2=PREV_AUTH_NOT_VALID)
[ 4319.613859] wlan0: authenticate with xx:xx:xx:xx:fa:80
[ 4319.663466] wlan0: send auth to xx:xx:xx:xx:fa:80 (try 1/3)
[ 4319.665869] wlan0: authenticated
[ 4319.669931] wlan0: associate with xx:xx:xx:xx:fa:80 (try 1/3)
[ 4319.674287] wlan0: RX AssocResp from xx:xx:xx:xx:fa:80 (capab=0x411 status=0 aid=3)
[ 4319.678976] wlan0: associated
[ 4319.679346] ath: EEPROM regdomain: 0x8348
[ 4319.679360] ath: EEPROM indicates we should expect a country code
[ 4319.679368] ath: doing EEPROM country->regdmn map search
[ 4319.679373] ath: country maps to regdmn code: 0x3a
[ 4319.679379] ath: Country alpha2 being used: US
[ 4319.679384] ath: Regpair used: 0x3a
[ 4319.679388] ath: regdomain 0x8348 dynamically updated by country element
[ 4460.160571] wlan0: deauthenticating from xx:xx:xx:xx:fa:80 by local choice (Reason: 2=PREV_AUTH_NOT_VALID)
[ 4465.650191] wlan0: authenticate with xx:xx:xx:xx:fa:80
[ 4465.704961] wlan0: send auth to xx:xx:xx:xx:fa:80 (try 1/3)
[ 4465.707455] wlan0: authenticated
[ 4465.715265] wlan0: associate with xx:xx:xx:xx:fa:80 (try 1/3)
[ 4465.725113] wlan0: RX AssocResp from xx:xx:xx:xx:fa:80 (capab=0x411 status=0 aid=3)
[ 4465.730581] wlan0: associated
[ 4465.730962] ath: EEPROM regdomain: 0x8348
[ 4465.730976] ath: EEPROM indicates we should expect a country code
[ 4465.730983] ath: doing EEPROM country->regdmn map search
[ 4465.730989] ath: country maps to regdmn code: 0x3a
[ 4465.730994] ath: Country alpha2 being used: US
[ 4465.730999] ath: Regpair used: 0x3a
[ 4465.731005] ath: regdomain 0x8348 dynamically updated by country element

在它保持连接期间,我可以访问网络,但速度很差,我怀疑它丢失了大部分数据包。

为了帮助解决问题,我决定绕过 NetworkManager 并手动连接到 WiFi:

user@ubuntu:~$ sudo systemctl disable wpa_supplicant
Removed /etc/systemd/system/multi-user.target.wants/wpa_supplicant.service.
Removed /etc/systemd/system/dbus-fi.w1.wpa_supplicant1.service.
user@ubuntu:~$ sudo systemctl stop wpa_supplicant
user@ubuntu:~$ sudo systemctl mask wpa_supplicant
Created symlink /etc/systemd/system/wpa_supplicant.service -> /dev/null.
user@ubuntu:~$ wpa_passphrase NetworkSSID NetworkPassword >prodwifi.wpa
user@ubuntu:~$ sudo wpa_supplicant -i wlan0 -c prodwifi.wpa 
Successfully initialized wpa_supplicant
wlan0: SME: Trying to authenticate with xx:xx:xx:xx:fa:80 (SSID='NetworkSSID' freq=2412 MHz)
wlan0: Trying to associate with xx:xx:xx:xx:fa:80 (SSID='NetworkSSID' freq=2412 MHz)
wlan0: Associated with xx:xx:xx:xx:fa:80
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: CTRL-EVENT-REGDOM-CHANGE init=COUNTRY_IE type=COUNTRY alpha2=US
wlan0: WPA: Key negotiation completed with xx:xx:xx:xx:fa:80 [PTK=CCMP GTK=CCMP]
wlan0: CTRL-EVENT-CONNECTED - Connection to xx:xx:xx:xx:fa:80 completed [id=0 id_str=]
wlan0: WPA: Group rekeying completed with xx:xx:xx:xx:fa:80 [GTK=CCMP]

然后,我在单独的终端中运行sudo dhclient -v wlan0以获取接口上的 IP。

到目前为止,我还没有遇到过任何问题,在过去的一个小时内,它甚至没有断开连接或取消认证。网络性能良好 - 我以超过 3Mb/s 的速度下载了一个测试文件。

这似乎表明问题出在 NetworkManager 的某个地方。考虑到系统日志中有关通过“本地选择”取消身份验证的消息和 PREV_AUTH_NOT_VALID 文本,似乎 NetworkManager 明确决定从网络取消身份验证,我只是不明白为什么。

有人能解释一下为什么会发生这种情况以及我该如何解决这个问题吗?

答案1

我弄清楚了问题的原因。经过几个小时的测试,我可以确认连接现在很稳定。

我很愿意提供解决方案,但事实上我在 Unix/Ubuntu StackExchange 网站上提出的最后三个问题被社区完全忽略了。甚至没有一条评论。对于“问答”网站来说,这已经够糟糕的了。

相关内容