The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 53     Votes:  0     ✅ Solution
Tags: networking   18.04   suspend   ethernet  
Link: 🔍 See Original Answer on Ask Ubuntu 🔗

URL: https://askubuntu.com/q/1156038
Title: Ethernet 'cable unpluged' when waking up laptop from sleep
ID: /2019/07/04/Ethernet-_cable-unpluged_-when-waking-up-laptop-from-sleep
Created: July 4, 2019
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


Same thing happened to me years ago on an older laptop and I used this script:

#!/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

Place the script in the directory /lib/systemd/system-sleep with the name r8169-reset. Mark the script executable with the command

sudo chmod a+x /lib/systemd/system-sleep/r8169-reset

Reboot and script will run automatically with every resume after suspend.

⇧ Failing to boot to grub with dual boot Dell laptop Can you install Ubuntu on the Raspberry Pi 4  ⇩