You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Ubuntu 20.04 有线网络连接异常问题

Ubuntu 20.04 有线网络连接异常问题

我看到你在GNOME和KDE Plasma之间切换桌面环境后,有线网卡突然罢工了——之前在GNOME明明正常,切换到KDE一段时间没碰有线,切回GNOME就出问题了。从你提供的诊断信息来看,核心问题很明确:你的RTL8111/8168有线网卡处于UNCLAIMED状态,这说明系统没成功加载对应的驱动模块。咱们一步步来解决这个问题:

解决步骤

1. 先确认驱动模块状态

首先检查系统是否加载了r8168驱动(lspci显示你的网卡对应的内核模块是r8168):

lsmod | grep r8168

如果没有任何输出,说明模块确实没加载,直接走到下一步。

2. 手动加载r8168模块

尝试手动加载驱动模块,看看能否让网卡被识别:

sudo modprobe r8168

加载完成后,再用lshw -c net检查网卡状态——如果不再显示UNCLAIMED,说明驱动生效了,此时可以尝试连接有线网络,应该能正常工作。

3. 设置驱动模块开机自动加载

如果手动加载有效,为了避免下次重启后问题复发,需要让r8168模块开机自动启动:

  • 打开modules文件:sudo nano /etc/modules
  • 在文件末尾添加一行:r8168
  • 按下Ctrl+O保存,回车确认,再按Ctrl+X退出编辑器

4. 排查r8169模块的干扰(可选)

虽然你的modprobe配置里没有黑名单r8169,但有时候Realtek的r8169通用驱动会和r8168专用驱动冲突。可以尝试把r8169加入黑名单:

  • 编辑r8168的配置文件:sudo nano /etc/modprobe.d/r8168-dkms.conf
  • 找到被注释的#blacklist r8169这一行,去掉前面的#,变成blacklist r8169
  • 保存退出后,更新initramfs:sudo update-initramfs -u
  • 重启系统,检查有线网络是否正常

5. 重新安装r8168-dkms驱动(如果上述步骤无效)

如果驱动文件可能损坏,试试重新安装r8168-dkms:

sudo apt purge r8168-dkms
sudo apt install r8168-dkms
sudo modprobe r8168

安装完成后重启系统,再检查网卡状态。


你提供的诊断信息汇总

以下是你给出的关键诊断输出,供参考:

无线网卡状态(正常工作)

$ sudo ethtool wlp2s0
Settings for wlp2s0:
Link detected: yes

有线网卡状态(UNCLAIMED)

$ sudo lshw -c net
*-network UNCLAIMED
description: Ethernet controller
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:01:00.0
version: 10
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix vpd cap_list
configuration: latency=0
resources: ioport:5000(size=256) memory:a4104000-a4104fff memory:a4100000-a4103fff
*-network
description: Wireless interface
product: RTL8821AE 802.11ac PCIe Wireless Network Adapter
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:02:00.0
logical name: wlp2s0
version: 00
serial: c8:3d:d4:3b:e9:71
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=rtl8821ae driverversion=5.15.0-57-generic firmware=N/A ip=192.168.1.129 latency=0 link=yes multicast=yes wireless=IEEE 802.11
resources: irq:128 ioport:4000(size=256) memory:a4000000-a4003fff

已安装内核相关包

# apt list --installed | grep -E '^linux'
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
linux-base/focal-updates,focal-updates,now 4.5ubuntu3.7 all [installed,automatic]
linux-firmware/focal-updates,focal-updates,now 1.187.35 all [installed,automatic]
linux-generic-hwe-20.04/focal-updates,focal-security,now 5.15.0.58.64~20.04.24 amd64 [installed]
linux-headers-5.15.0-57-generic/focal-updates,focal-security,now 5.15.0-57.63~20.04.1 amd64 [installed]
linux-headers-5.15.0-58-generic/focal-updates,focal-security,now 5.15.0-58.64~20.04.1 amd64 [installed,automatic]
linux-headers-5.4.0-137-generic/focal-updates,focal-security,now 5.4.0-137.154 amd64 [installed,automatic]
linux-headers-5.4.0-137/focal-updates,focal-updates,focal-security,focal-security,now 5.4.0-137.154 all [installed,automatic]
linux-headers-generic-hwe-20.04/focal-updates,focal-security,now 5.15.0.58.64~20.04.24 amd64 [installed,automatic]
linux-headers-generic/focal-updates,focal-security,now 5.4.0.137.135 amd64 [installed]
linux-hwe-5.15-headers-5.15.0-57/focal-updates,focal-updates,focal-security,focal-security,now 5.15.0-57.63~20.04.1 all [installed,automatic]
linux-hwe-5.15-headers-5.15.0-58/focal-updates,focal-updates,focal-security,focal-security,now 5.15.0-58.64~20.04.1 all [installed,automatic]
linux-image-5.15.0-57-generic/focal-updates,focal-security,now 5.15.0-57.63~20.04.1 amd64 [installed]
linux-image-5.15.0-58-generic/focal-updates,focal-security,now 5.15.0-58.64~20.04.1 amd64 [installed,automatic]
linux-image-generic-hwe-20.04/focal-updates,focal-security,now 5.15.0.58.64~20.04.24 amd64 [installed,automatic]
linux-libc-dev/focal-updates,focal-security,now 5.4.0-137.154 amd64 [installed,automatic]
linux-modules-5.15.0-57-generic/focal-updates,focal-security,now 5.15.0-57.63~20.04.1 amd64 [installed]
linux-modules-5.15.0-58-generic/focal-updates,focal-security,now 5.15.0-58.64~20.04.1 amd64 [installed,automatic]
linux-modules-extra-5.15.0-57-generic/focal-updates,focal-security,now 5.15.0-57.63~20.04.1 amd64 [installed]
linux-modules-extra-5.15.0-58-generic/focal-updates,focal-security,now 5.15.0-58.64~20.04.1 amd64 [installed,automatic]
linux-sound-base/focal,focal,now 1.0.25+dfsg-0ubuntu5 all [installed,automatic]

DKMS状态

# dkms status
nvidia, 525.78.01, 5.15.0-57-generic, x86_64: installed
nvidia, 525.78.01, 5.15.0-58-generic, x86_64: installed
nvidia, 525.78.01, 5.4.0-137-generic, x86_64: installed
rtl8821ce, 5.5.2.1, 5.15.0-57-generic, x86_64: installed
rtl8821ce, 5.5.2.1, 5.15.0-58-generic, x86_64: installed
rtl8821ce, 5.5.2.1, 5.4.0-137-generic, x86_64: installed

网卡模块配置及日志

# grep r8169 /etc/modprobe.d/*
/etc/modprobe.d/r8168-dkms.conf:# map the specific PCI IDs instead of blacklisting the whole r8169 module
/etc/modprobe.d/r8168-dkms.conf:# to blacklist the whole r8169 module
/etc/modprobe.d/r8168-dkms.conf:#blacklist r8169

# dmesg | grep r8169
<no output>

# lspci -knn | grep Eth -A3
01:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 10)
Subsystem: Lenovo RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [17aa:384c]
Kernel modules: r8168
02:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8821AE 802.11ac PCIe Wireless Network Adapter [10ec:8821]
Subsystem: Lenovo RTL8821AE 802.11ac PCIe Wireless Network Adapter [17aa:a814]

备注:内容来源于stack exchange,提问作者djoh

火山引擎 最新活动