Ubuntu下WIFI不稳定问题

初步尝试

Ubuntu下无线网络总是不稳定,显示WIFI开着,密码也正确,但是连接时却一直连不上,显示一直connecting,建立WIFI连接时可以看到有如下syslog:

Aug 15 20:00:25 ubuntu wpa_supplicant[1071]: wlp3s0: Authentication with ff:ea:da:e9:5a:3d timed out.
Aug 15 20:00:25 ubuntu wpa_supplicant[1071]: wlp3s0: CTRL-EVENT-DISCONNECTED bssid=ff:ea:da:e9:5a:3d reason=3 locally_generated=1
Aug 15 20:00:25 ubuntu wpa_supplicant[1071]: wlp3s0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid=“WIFI” auth_failures=1 duration=10 reason=CONN_FAILED
Aug 15 20:00:25 ubuntu NetworkManager[1072]: [1629028825.1315] sup-iface[0x56030ddd5a30,wlp3s0]: connection disconnected (reason -3)

显示认证时失败,物理连接被断开,显示在界面上就是一直connecting,不能点cancel,只能换个WIFI连。
开关WIFI不起作用;重启并不一定起作用;我怀疑是Ubuntu下网卡驱动的问题,也怀疑是因为安装aircrack-ng造成驱动有问题,卸载它也没有起作用;重启NetworkManager也不行(通过systemctl),同时在systemctl下能看到这么一个设备:

sys-subsystem-net-devices-wlp3s0.device                                                   
loaded active plugged   BCM43142 802.11b/g/n

想重启下它却不行,这应该对应的是一个物理网卡了,stoprestart都不起作用,除非把它拔了。
后来记起rfkill命令,了解一番后,它是通过命令行开关无线功能,和通过设置开关没啥区别

重装驱动

WIFI使用的是哪个驱动呢?Linux驱动在哪里看呀?都不知道!
bing,modules Linux的驱动是作为一个module随机运行的:

/etc/modules - kernel modules to load at boot time

ubuntu论坛中讨论出好好几个方法:How do i remove wireless drivers?
先说总结方法,后面记录写额外的命令:sudo lshw -C network可以看出和网络相关的硬件,一部分输出如下:

*-network
description: Wireless interface
product: BCM43142 802.11b/g/n
vendor: Broadcom Inc. and subsidiaries
physical id: 0
bus info: pci@0000:03:00.0
logical name: wlp3s0
version: 01
serial: ff:bb:db:d9:10:a7
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=wl0 driverversion=6.30.223.271 (r587334) ip=192.168.43.3 latency=0 multicast=yes wireless=IEEE 802.11
resources: irq:19 memory:d1100000-d1107fff

可以看到driver是wl0, 然后lsmod | grep wl,得到输出

wl 6447104 0
cfg80211 634880 1 wl

卸载wl rmmod -f wl,此时设置里的WIFI都没有了,说明驱动卸载成功了,(为什么grep的是wl而非wl0?首先wlan想到wl,还有个原因是linux中个整eth0,wlp3s0,中末尾的0都只表示某种顺序,那去掉0呗,最重要的是grep wl0没输出啊,就,就尝试一下)
那么怎么装回来呢?
当初安装驱动是通过Software & Updates这个软件配置的(或者敲入命令software-properties-gtk),Additional Drivers里有带驱动,我的显示是Linux STA 代码源自bcmwl-kernel-source,切换一下(轮换修改两次)是否使用这个Driver就又自动装回来了,此时lsmod又能过滤出wl,WIFI设置又回来了,还有另一种安装方式是 sudo apt install bcmwl-kernel-source ;至此一个驱动的卸载重装过程就结束了。

NDIS

论坛中还提到一个程序:ndiswrapper

The NDISwrapper project provides a Linux kernel module that loads and runs Windows kernel API and NDIS (Network Driver Interface Specification) API drivers supplied by the vendors within the Linux kernel.

NDIS:(Network Driver Interface Specification)看了微软官网的描述,基于这个API开发的驱动就可以在支持Windows系统的所有平台使用.
进而ndiswrapper又让驱动能在Linux内核上运行,根据官网描述,只支持WindowsXP的驱动(这篇文章还描述了如何安装WindowsXP驱动):

Windows XP drivers are required to be used. NDISwrapper does not support NDIS 6.x (Windows Vista/7/8) at this time.

微软官网对其Windows版本与NDIS版本的对应关系:windows-hardware/drivers/network/overview-of-ndis-versions, Vista以后都是6.0以上了,Win10 1903 对应的是6.83

支持的PCI网卡的信息:http://ndiswrapper.sourceforge.net/wiki/index.php/Category:PCI,我的网卡是博通BCM43142,没在此列,说明此路我是走不通了。

  • Broadcom 5343
  • Broadcom BCM4310
  • Broadcom BCM4311
  • Broadcom BCM4318
  • Broadcom BCM4318 HP
  • Broadcom BCM4318 HP COMPAQ V2415LA
  • Broadcom BCM4318 HP nx6125
  • Broadcom BCM94306 Compaq Presario 3160
  • BroadcomBCM94306MP HP Pavilion ze4560us
问题没解决?

Ubuntu网卡问题解决指引:https://help.ubuntu.com/stable/ubuntu-help/net-wireless-troubleshooting-hardware-check.html.en
AskUbuntu指引:https://askubuntu.com/questions/235279/my-wifi-adapter-is-not-working-at-all-how-to-troubleshoot
Ubuntu下博通无线网卡驱动的选择:https://askubuntu.com/questions/55868/installing-broadcom-wireless-drivers/60395#60395
尽量选择安装驱动sudo apt install firmware-b43-installer sudo apt install linux-firmware,注意安装完后从module黑名单中放出来!
上面问题里有个回答:https://askubuntu.com/questions/55868/installing-broadcom-wireless-drivers/67806#67806说得很详细,列举了可使用4个驱动,我目前就是使用的旧的、不建议的驱动

二更:
但是我安装完 firmware-b43-installer并不管用,此时如果将wl加入黑名单(/etc/modprobe.d/blacklist.conf),WIFI完全就没了,一定是哪里出问题了!解释不通,有点恼火。
又处处尝试。偶然看到:键入命令lspci -nn -d 14e4: (14e4是厂商id,输出中冒号后面是产品id)我的是[14e4:4365] (rev 01)而非[14e4:4365] ,所以b43( firmware-b43-installer即b43 module)不支持是正常的,第三个链接回答里列举的[14e4:4365] (rev 01)应该使用:bcmwl-kernel-source Software & UpdateAdditional Drivers里那个。
这里的bcmwlwl是否就是wl module呢?当WIFI设置都没了的时候,rmmod wl而后modprobe wl就把驱动安装回来了。
bcmwl驱动禁止了的modules如下代码块,最后一个配置testfile是我测试电脑重启后,自己修改这个文件是否会被复原,测试来看是不会的。而且文中的bcmwl就是bcmwl-kernel-source 呀!我还以为它是一个命令。

# Warning: This file is autogenerated by bcmwl. All changes to this file will be lost.
blacklist b43
blacklist b43legacy
blacklist ssb
blacklist bcm43xx
blacklist brcm80211
blacklist brcmfmac
blacklist brcmsmac
blacklist bcma
blacklist testfile

这下全弄明白了。我只能使用bcmwl-kernel-source而不是b43 也没有NDISwindows驱动。
而且内核没有自己带的驱动,自己安装相应驱动后,要将其写入内核image,看起来是这样子。是因为看到个命令:update-initramfs: The update-initramfs script manages your initramfs images on your local box. It keeps track of the existing initramfs archives in /boot. 将内核变动固化到磁盘,下次开机再解压出来。

今天帮助我弄清这个一个debian wiki:https://wiki.debian.org/bcm43xx 这里对各驱动的支持网卡描述更详细。
三更:
装了Ubuntu22.04后再没遇到这个问题,建议大家都更新
但是最近用着用着WiFi没了,蓝牙功能还在,通过 lsmod lshw均无法发现WiFi相关信息,搜索一番原来是内核引入了bug-Cannot find wifi adapter after kernel update to 5.19.0-40-generic 而我的新旧内核分别是5.15.0-43 5.19.0-38 所以要等到42才能修复,第一次赶上时新的bug。
那么,在官方修复内核前,1. 我怎么修改默认启动内核 2.我怎么通过一些内核hook自行修复
附录:

  1. 新命令

    • lsmod
    • rmmod
    • modprobe -f
    • sudo lspci lspci -vvnn | grep 802 sudo lspci -k
    • lshw lshw -C Network
    • iwconfig
    • update-initramfs sudo update-initramfs -u
    • sudo apt-cache search linux-image-5.19.0-
  2. 新目录

    • /etc/modprobe.d/blacklist.conf
    • /usr/src kernel headers
  3. 新概念

  • Linux Kernel Modules https://wiki.archlinux.org/title/Kernel_module & DKMS
    DKMS: Dynamic Kernel Module Support
    Today, all necessary modules loading is handled automatically by udev, so if you do not need to use any out-of-tree kernel modules, there is no need to put modules that should be loaded at boot in any configuration file.
    当今,所有必须得modules都被udev自动处理,如果你不使用out-of-tree的modules,那么就不用把modules放在自启配置文件中。
    如果说module是编进内核的话,那么内核更新后的怎么知道旧内核的modules? 这是我在看wiki前的疑问,显然,wiki上说了,in-tree module应该在新版本上有,但是Ubuntu系统总是打破 ABI ;如果是自己的modules:若是通过DKMS安装,则升级内核的时候会再次编译 Plain kernel modules are only built for very version they were compiled for and keep working when updates do not break the ABI.
    另外
  • udev 第一次见udev是一个挖矿病毒用它, arch linux的wiki讲得很清楚了

udev is a userspace system that enables the operating system administrator to register userspace handlers for events. The events received by udev’s daemon are mainly generated by the (Linux) kernel in response to physical events relating to peripheral devices. As such, udev’s main purpose is to act upon peripheral detection and hot-plugging, including actions that return control to the kernel, e.g., loading kernel modules or device firmware. Another component of this detection is adjusting the permissions of the device to be accessible to non-root users and groups.As the successor of devfsd and hotplug, udev also manages device nodes in the /dev directory by adding, symlinking and renaming them. udev replaces the functionality of both hotplug and hwdetect.
udev是一个用户空间系统,它可以使系统管理员为事件注册用户空间的处理器。这些事件通常是Linux内核对外部设备的物理事件做出的相应事件,udev守护进程就收到这些事件。因此,udev的主要目的是执行外围设备检测和热拔插做;包括将控制返回给内核的操作,比如,加载内核modules活着设备固件。另一个检测是调整设备权限使非root用户、组能访问。作为 devfsd和hotplug的继任者,udev也管理/dev目录下的设备,通过增加、链接和重命名他们。从功能上替代了这两者。
udev会在 /etc/udev/rules.d/ /usr/lib/udev/rules.d/加载规则。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值