ubuntu 18.04 喚醒后丟失網絡連接


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM