Linux 无线网络断开的解决方案

Linux 系统用着用着突然发现电脑上的 WiFi 图标不见了,电脑无法连接到无线网。这可急坏了,找遍设置也没找到哪里可以重新打开无线网,感觉就像是凭空消失了一样。折腾了一天,终于把无线网络恢复正常了。

这篇文章就来梳理一下在 Linux 上修复无线网络的一些简单常用的操作。

首先,我们可以使用 rfkill 命令查看无线设备的状态。

$> rfkill list
# 正常情况应该显示如下内容
0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
1: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no

如果无线网络设备(Wireless LAN)显示 Soft blocked: yes ,即软阻塞,通常原因是软件层面关闭了无线网络。笔记本电脑可以看看是否误触到了飞行模式按键,导致无线网络被关闭。飞行模式按键通常是 Fn + F12Fn + INSERT

如果显示 Hard blocked: yes ,即硬阻塞,通常原因是网卡或网卡驱动损坏,网卡损坏的几率相对较小,可以尝试重新安装驱动是否能够解决问题。使用 lspci 指令查看电脑网卡的型号,然后从网上下载对应型号的网卡驱动进行编译安装。

lspci | grep Ethernet
  • lspci 指令用于查看所有的 pci 设备信息。pci 是一种总线,pci 设备就是通过 pci 总线连接的设备。如今,我们常用的设备大部分都采用的是pci总线,如网卡、存储等。

rfkill 命令显示的内容正常后,我们再用 ifconfig 命令查看网络设备的状态。

$> ifconfig
eno1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 84:a9:3a:1c:7f:e4  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 736  bytes 59264 (57.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 736  bytes 59264 (57.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

可以看到,此时可用的网络设备只显示了有线网卡(以太网接口 eno1)和回环接口(lo),并没有显示无线网卡。如果使用 -a 参数展示所有的网络设备,则可以看到无线网卡(wlo1)的信息。

$> ifconfig -a
eno1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 84:a9:3a:1c:7f:e4  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 736  bytes 59264 (57.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 736  bytes 59264 (57.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlo1: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 18:1e:ea:a6:0b:5f  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

虽然我们解决了阻塞问题,但无线网卡仍处于关闭状态。我们需要手动开启无线网卡。

$> sudo ifconfig wlo1 up

开启后,再执行 ifconfig 命令就能够看到无线网卡(wlo1)的信息啦。等待一会儿之后,WiFi 的图标就能又重新出现在了我们的桌面上。

如果仍没有效果,可以尝试重启网络服务。

$> systemctl restart network-manager

ifconfig 是在 Linux 上调试网络设备的重要工具,下面列举了 ifconfig 的一些常用操作。

# 显示 up 状态的网络设备信息
$> ifconfig    

# 显示所有网络设备信息         
$> ifconfig -a     

# 启动 eth0 网卡 
$> ifconfig eth0 up     

# 关闭 eth0 网卡
$> ifconfig eth0 down   

# 给 eth0 网卡配置 IP 地址
$> ifconfig eth0 192.168.1.56  

# 给 eth0 网卡配置 IP 地址,并加上子掩码 
$> ifconfig eth0 192.168.1.56 netmask 255.255.255.0 

猜你喜欢

转载自blog.csdn.net/Teri_Tor/article/details/109958945