Ubuntu – Ubuntu 18.04 – Ethernet disconnected after suspend


Ethernet does not resume after suspend.

sudo service network-manager restart

does not work. Only restart solves problem.

Best Answer

The main Ubuntu bug tracking this issue, at least for network kernel module r8169, seems to be:


I'd encourage everyone that is affected by this issue to go there and mark that it affects you, so that the maintainers have a better sense of how serious it is.

I'm running a fresh install of Xubuntu 18.04, and my Ethernet interface uses kernel module r8169, which I discovered running:

sudo lshw -C network

There'll be 2 groups of info, one starting with description: Ethernet interface, and another with description: Wireless interface. Under description: Ethernet interface, look for a line starting with configuration:, like this:

configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl_nic/rtl8105e-1.fw ip= latency=0 link=yes multicast=yes port=MII speed=100Mbit/s

The driver will be here: driver=.

Systemd runs all executable scripts under /lib/systemd/system-sleep before and after suspend, passing 2 parameters, $1 is the state (pre, before suspend, or post, after suspend), and $2 is the action (suspend, hibernate, hybrid-state, or suspend-then-hibernate). This is documented in the man page for systemd-suspend.service.

We need to reload the module for the Ethernet interface when resuming from suspend, after suspend. So I created script /lib/systemd/system-sleep/r8169-refresh:


PROGNAME=$(basename "$0")

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"

and made it executable:

chmod +x /lib/systemd/system-sleep/r8169-refresh

The messages logged from the script will go to /var/log/syslog tagged with the name of the script and its PID. This way you can check whether the script reloaded the kernel module:

grep r8169-refresh /var/log/syslog
Related Question