Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller on Ubuntu 22.04.3 LTS

Written by

in

*Disclaimer* – While I got this all working in the end, it was a bit of trial and error to figure out exactly what to do. Did my research on a few forum posts and reading out the solutions. But some of it didn’t apply to the situation I was in. If you are like me and had r8168-dkms working previously, and pulled in a new update for Ubuntu 22.04 LTS, give the builtin driver r8169 a try. This advice would apply to Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller, it might also apply to other Realtek NICs, but I cannot verify if it would work on others or not.

Also this advice ASSUMES you are slightly comfortable with using terminal on Linux, via local machine or remote SSH. [[email protected]]

I believe it all started when I updated the main Ubuntu 22.04 to 22.04.2, I went searching through the internet to see why my Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller was no longer connecting to the wired network. This was a big deal to me because the system I was running this on was a headless server (thankfully still in the house) that I was trying to figure out why I could not remote SSH into it. (I also have AnyDesk installed on the operating system, for when I was lazy and didn’t get too familiar with terminal yet). Thankfully the WiFi NIC was still operable, so I was connecting a very small 5” monitor (https://www.amazon.com/gp/product/B07B8JNKT3?ie=UTF8&th=1) to the system, along with a keyboard and mouse to see what the heck was going on.

From what I was seeing online, it looks like the r8169 NIC driver (that comes default with the Ubuntu install) was not functioning correctly and I needed to run r8168-dkms on it, disabling the default driver. From what I could ascertain in the current situation, r8169 could not enable the Gigabit Ethernet NIC, so following the Debian commands for installing such a thing from the Linux repository “apt”:

sudo apt update

sudo apt install r8168-dkms

After running that command and sending off a “sudo reboot now” command in console to make sure that the configuration stays intact after a reboot, I saw it worked well and the connection was stable after a few hours.

I bring this all up because TODAY I decided to restart the server (again with a remote SSH terminal session) after pulling in new updates for Ubuntu using apt update and apt upgrade. My connection was closed by host, but it wasn’t coming back. Thinking the server froze up or some other issue, I force restarted it at the power button on the unit itself. SSH still wasn’t working. So I pulled up my trusty 5” monitor, keyboard and mouse and locally attached it all to see what was going on. Same issue as before, missing Ethernet connection from the status bar (top right) and from the settings menu. Again WiFi was still working, so I connected that to my guest WiFi in my place and started working on updating the Ethernet NIC driver.

Played the “search the Internet game for an answer”, I had a hunch that the r8168 driver wasn’t working correctly and decided to give the stock (built-in) Realtek r8169 driver a chance. In order for me to re-enable r8169, I had to purge and remove dependent packages and configurations like so:

sudo apt remove r8168-dkms

sudo apt remove — auto-remove r8168-dkms

sudo apt purge r8168-dkms

sudo apt purge — auto-remove r8168-dkms

Interestingly enough after a reboot, it didn’t automatically fix it after removing the r8168-dkms, so after poking around some more I put in two more commands:

rmmod r8169

sudo modprobe r8169

After typing in the last command, the server was able to recognize the Ethernet controller and immediately connected back to the wired network! Once I verified the connection was up and active, I disabled the WiFi once again on the machine to solely connect to the network through the Ethernet port.

P.S. – I did the command lspci in terminal to list out the hardware to verify exactly what make and model the Ethernet Controller was. By doing so I was able to use that info while searching around the Internet to figure out what the issue was in the first place.

This is all running on a HP ProDesk 400 G5 Desktop Mini i5-9500T.

Website sources I used mainly to try to figure out what the heck to do: 

https://forum.proxmox.com/threads/after-update-kernel-from-6-2-16-19-to-6-5-11-3-network-not-work-anymore.136831/

https://bugs.launchpad.net/ubuntu/+source/linux-signed/+bug/1876593