登录后无法连接网络

登录后无法连接网络

我遇到了一个奇怪的问题:我使用 WiFi 连接互联网。它运行正常,直到我决定离开电脑一段时间。当我回来时,我登录电脑却无法上网。WiFi/网络图标保持不变(完全连接),但当我尝试 ping 一个有效的互联网地址时,我得到了ping: connect: Network is unreachable

使用 systemctl 重新启动 networking.service 不起作用。断开连接然后再次连接到 WiFi 热点可以解决问题。

编辑: sudo lshw -C network输出:

  *-network                 
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: enp2s0f0
       version: 0e
       serial: 54:05:db:73:da:dd
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.8.0-41-generic latency=0 link=no multicast=yes port=MII
       resources: irq:51 ioport:3400(size=256) memory:fd814000-fd814fff memory:fd800000-fd803fff
  *-network
       description: Wireless interface
       product: Wi-Fi 6 AX200
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: wlp3s0
       version: 1a
       serial: 34:c9:3d:2b:a6:42
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=iwlwifi driverversion=5.8.0-41-generic firmware=55.d9698065.0 cc-a0-55.ucode ip=10.0.0.28 latency=0 link=yes multicast=yes wireless=IEEE 802.11
       resources: irq:102 memory:fd700000-fd703fff
  *-network
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:05:00.0
       logical name: enp5s0
       version: 15
       serial: 54:05:db:73:da:dc
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.8.0-41-generic firmware=rtl8168h-2_0.0.2 02/26/15 latency=0 link=no multicast=yes port=MII
       resources: irq:69 ioport:2000(size=256) memory:fd504000-fd504fff memory:fd500000-fd503fff

我该如何避免这个问题?谢谢!

答案1

您的无线网络可能因为电源管理而掉线;电源管理是指无线网卡在闲置期间部分关闭以节省电池电量,然后在活动恢复时无缝重新启动的功能。让我们禁用省电功能,看看是否有帮助。从终端:

sudo sed -i 's/3/2/' /etc/NetworkManager/conf.d/*

有沒有改善?

答案2

从输出结果来看lshw -C network,您的机器正在使用该无线网卡的正确驱动程序。所以,让我们看看我们能否在 chili555 的答案的基础上再添加一些更有效的东西。

power_save首先,我们将网卡的模式设置为,以0防止网络循环到IDLE可能会卡住的位置:

  1. 打开终端(如果尚未打开)

  2. 编辑iwlwifi.conf文件如下root

    sudo vi /etc/modprobe.d/iwlwifi.conf
    
  3. 添加/修改此行,确保其值为0

    options iwlwifi power_save=0
    

    接下来,我们需要将power_scheme值设置为1,否则power_save每次重启时模式都会重置。

  4. 将此行添加/修改到同一个文件,确保其值为1

    options iwlmvm power_scheme=1
    
  5. 重启

    重新启动并不是完全必要的,因为禁用并重新启用无线可以完成同样的工作,但重新启动通常可以确保提前清除任何“垃圾”。

就是这样。一旦进行了这两个更改,无线网卡将永远不会完全地除非您将计算机设置为飞行模式或禁用无线设备,否则计算机将关闭。这确实会导致计算机在锁定或暂停时耗电量增加,但它往往值得您付出这样的代价。

希望这能解决你的问题

相关内容