每当我将笔记本电脑从睡眠状态唤醒时,我都会遇到这个奇怪的问题,无法检测到以太网连接。我设法通过删除网络模块并再次添加它来使其正常工作。
rmmod r8169
modprobe r8169
但是我想让这些唤醒无缝进行,我不想在膝上电脑唤醒时手动运行这些命令以建立以太网连接。
uname -a
Linux pc-name 4.16.0-041600-generic #201804012230 SMP Sun Apr 1 22:31:39 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
ifconfig -a
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.50 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::7020:d2e9:225b:9004 prefixlen 64 scopeid 0x20<link>
ether 54:48:10:e3:a3:56 txqueuelen 1000 (Ethernet)
RX packets 5919 bytes 3436132 (3.4 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5752 bytes 667433 (667.4 KB)
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 8101 bytes 610092 (610.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8101 bytes 610092 (610.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.114 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::392d:4fdb:372f:3381 prefixlen 64 scopeid 0x20<link>
ether 34:e1:2d:f8:1d:f3 txqueuelen 1000 (Ethernet)
RX packets 9592 bytes 4262963 (4.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6766 bytes 1125519 (1.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
请让我分享有助于解决问题的其他信息,但我不知道哪些。
谢谢
答案1
几年前,我在一台旧笔记本电脑上也发生过同样的事情,我使用了这个脚本:
#!/bin/bash
# NAME: r8169-reset
# PATH: /lib/systemd/system-sleep
# DESC: Reset Ethernet card after suspend, not working automatically
# DATE: Feb ?? 2017. Modified: Aug 5, 2018.
MYNAME=$0
restart_ethernet() {
/usr/bin/logger $MYNAME 'restart_ethernet(r8169) BEGIN'
/sbin/modprobe -v -r r8169
/sbin/modprobe -v r8169
/usr/bin/logger 'systemctl restart NetworkManager.service (SUPPRESED)'
/usr/bin/logger $MYNAME 'restart_ethernet(r8169) END'
}
/usr/bin/logger $MYNAME 'case=[' ${1}' ]'
case "${1}/${2}" in
hibernate|suspend|pre*)
;;
resume|thaw|post*)
restart_ethernet;;
esac
/lib/systemd/system-sleep
将脚本放在名为 的目录中r8169-reset
。使用命令将脚本标记为可执行
sudo chmod a+x /lib/systemd/system-sleep/r8169-reset
重新启动并且脚本将在每次挂起后恢复时自动运行。
答案2
在 中terminal
输入sudo lshw -C network
,然后查找如下行:
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
注意 8168。
如果您有类似的控制器,您可以尝试安装此驱动程序,看看它是否可以解决您的问题。
sudo apt-get update
sudo apt-get install dkms r8168-dkms