Ubuntu 18.04 - Ethernet disconnected after suspend
Solution 1
The main Ubuntu bug tracking this issue, at least for network kernel module r8169, seems to be:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1752772
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=192.168.100.6 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
:
#!/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
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
Solution 2
Here's another simple(r?) solution: create a systemd service whose only task is to unload/reload the module after a suspend cycle (I named it /etc/systemd/system/fix-r8169.service):
[Unit]
Description=Fix RTL-8169 Driver on resume from suspend
After=suspend.target
[Service]
User=root
Type=oneshot
ExecStartPre=/sbin/modprobe -r r8169
ExecStart=/sbin/modprobe r8169
TimeoutSec=0
StandardOutput=syslog
[Install]
WantedBy=suspend.target
Then just execute systemctl enable fix-r8169.service
, and you should be set!! Systemd will now automagically unload-and-reload your module upon wake from suspend.
Cheers!
Solution 3
It happened to me too.
Unload/reload network kernel modules/drivers works.
Mine is r8169, so (as root): (I typed by hand, so there was a delay)
sudo modprobe -r r8169
sudo modprobe -i r8169
I also removed mii during my first try. Not necessary though.
Solution 4
I had the same problem and i found this solution.
run:
sudo lshw -C network
to find your network card kernel moduleIn *-network, description: Ethernet interface, in configuration field found
driver=sky2
for me. sky2 is a ethernet network kernel module for my laptop.I create a file sky2.sh into:
/lib/systemd/system-sleep/
folder with#!/bin/bash modprobe -r sky2 # unload sky2 kernel module modprobe -i sky2 # reload sky2 kernel module
and change the permissions with:
sudo chmod a+x sky2.sh
After that the problem solved.
Solution 5
It detects the Ethernet Connection?
then
open NetworkManager.conf
sudo nano /etc/NetworkManager/NetworkManager.conf
Comment (Add #) the dns=dnsmasq
[main]
plugins=ifupdown,keyfile,ofono
#dns=dnsmasq
[ifupdown]
managed=true
Restart the Network manager
sudo service network-manager restart
Related videos on Youtube
aaaa
Updated on September 18, 2022Comments
-
aaaa over 1 year
Ethernet does not resume after suspend.
sudo service network-manager restart
does not work. Only restart solves problem.
-
HEKTO almost 5 yearsThis problem is back for me in Xubuntu 18.04.2, kernel 4.15.0-54
-
-
aaaa about 6 years[main] plugins=ifupdown,keyfile [ifupdown] managed=true [device] wifi.scan-rand-mac-address=no
-
aaaa about 6 yearsthis is what I have in the file....
-
Santhosh Veer about 6 yearsdid you update the conf file Previously? if yes reboot & check
-
aaaa about 6 yearsI tried your fix Santhosh Veer. Still greyed out. Ethernet.
-
Santhosh Veer about 6 yearsrun this command
systemctl status NetworkManager.service
to check the error -
aaaa about 6 yearssudo modprobe -i r8169
-
aaaa about 6 yearsworked! do I have to do this manually now all the time i resume?
-
Paulo Marcel Coelho Aragão almost 6 yearsmadzohan, I feel it might be redundant to add your edit, since I mentioned twice in the answer that the script has to be executable: "systemd runs all executable scripts under /lib/systemd/system-sleep", and also "I created and made executable script /lib/systemd/system-sleep/r8169-refresh"
-
Fabby almost 6 yearsWelcome to Ask Ubuntu! ;-) Could you please review my edits and also review the editing help to improve the readability of your answers in the future... ;-)
-
Paulo Marcel Coelho Aragão almost 6 yearsThis was fixed in kernel 4.15.0-24.26, released on 07/01/2018, so the workaround is not needed anymore.
-
Danfro almost 6 yearsI have this problem on my laptop since installing some updates a few days ago. The solution given above does still solve the issue. Thanks a lot!
-
Paulo Marcel Coelho Aragão almost 6 years@Daniel, could you post the output of: apt policy linux-image-generic ? This issue should have been solved since 07/01/2018, this workaround shouldn't be needed anymore.
-
WinEunuuchs2Unix over 5 yearsIt's not just 18.04. In 16.04 the rtl8169 kernel driver had to be unloaded and loaded after suspend too: askubuntu.com/questions/950871/…
-
Gemechu Fanta Garuma over 5 yearsI was looking around in the internet for this answer. Thanks, it really solves the problem.
-
Dominic108 over 5 yearsThey say that it is not needed anymore, but I had the same problem and tried this solution and it worked. In my case, the driver was sky2, so I had to edit the script.
-
Dominic108 over 5 yearsThis is the same as the accepted solution, without the logging function.
-
Dominic108 over 5 yearsThis the same as the accepted solution, but without putting it in a script that will be executed at resume and without the logging function.
-
wjandrea over 5 yearsThis is not really an answer, unless you're suggesting to use kernel 4.13.
-
Michael over 5 yearsI have this problem too, but my Ethernet driver is "e1000e". I'm running the 4.15.0.43.45 kernel. This answer does appear to fix the issue.
-
Michael over 5 yearsThere appears to be a race condition (?) between reinserting the module and networking getting reconfigured, as about 10% of the time even with this method I still keep getting the "network is disconnected" notification every so often and never get connected.
-
kxr about 5 yearsProblem still here after standby (with sky2 driver) - and fixed by those modprobe's on a laptop. Linux HPC 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
-
alper over 4 yearsAfter making those changes I have suspended manually
systemctl suspend
and still having the same error. @Paulo Marcel Coelho Aragão -
jc00ke almost 4 yearsJust tested this on Ubuntu 20.04 (Regolith 1.4) on a Dell XPS 13 connected to a Thunderbolt dock and it worked flawlessly. :chef: :kiss: Thanks @diego-rivera!
-
Thomas Ferris Nicolaisen almost 4 yearsExactly the same here. Only replace the module with
r8152
for the Dell XPS 13 9360. Thanks! -
Ruth over 3 yearsThis worked perfectly on my 20.04 desktop, with a wifi card using the ath9k drivers. Thank you!
-
Lizardx over 3 yearsthis should be the accepted answer.
-
Rodrigo Soares almost 3 yearsIncluding grep to find the driver will be easier: sudo lshw -C network | grep driver=
-
Admin almost 2 yearsTry the steps manually first - on my system the rmmod failed because of dependencies... had to stop network-manager service, then remove and later insert some more modules in specific order and start network-manager again...