reference: https://askubuntu.com/questions/1029250/ubuntu-18-04-ethernet-disconnected-after-suspend

sudo modprobe -r r8169
sudo modprobe -i r8169

如何查找使用的网卡驱动

sudo lshw -C network

一般description为Ethernet interface的为本机有线网卡
然后configuration这一栏找到driver=,后面就是使用的驱动
比如:
*-network
description: Ethernet interface
....
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl8168e-3_0.0.4 03/27/12 ip=192.168.11.181 latency=0 link=yes multicast=yes port=MII speed=1Gbit/s
可以看到我的电脑有线网卡使用的时r8169的驱动

添加脚本自动重新加载网卡驱动

  • 在/lib/systemd/system-sleep/目录下创建r8169-refresh,内容如下:
#!/bin/bash

PROGNAME=$(basename "$0")
state=$1
action=$2

function log {
   logger -i -t "$PROGNAME" "$*"
}

log "Running $action $state"

if [[ $state == post ]]; then
   modprobe -r r8169 \
   && log "Removed r8169" \
   && modprobe -i r8169 \
   && log "Inserted r8169"
fi
  • 添加可执行权限
sudo chmod +x /lib/systemd/system-sleep/r8169-refresh

相关文章:

  • 2021-04-02
  • 2022-02-09
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-09-24
  • 2021-12-20
  • 2022-12-23
猜你喜欢
  • 2021-11-05
  • 2021-09-29
  • 2022-01-15
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案