r8168 driver problems 😔

This morning was rather unpleasant, when I woke up to notifications that my server decided to randomly off itself in the middle of the night. Upon digging, it turns out that the network driver connecting my RealTek Ethernet Interface just up and vanished. Seems like someone has cursed me :/

I went about the diagnosis by first trying the following methods.

ifconfig -a     # Does not return eth0 or alternative representations
lspci -vv       # Returns the detection of the  Realtek Controller but does not have any kernel driver (suspicious?)
lshw -C network # Prints network UNCLAIMED

Then, I managed to identify that the driver I needed wasn’t even getting loaded onto the kernel. To reinstall the r8168 driver, you need to download these links to a hard drive/thumb drive.

Then install these packages using dpkg. And load the module using modprobe.

# An example with my specific linux header files
sudo dpkg -i linux-headers-5.3.0-1026-gke.deb
sudo dpkg -i r8168-dkms_8.047.02-1_all.deb

# Black list a bad actor driver with known problems
echo "blacklist r8169" > /etc/modprobe.d/blacklist.conf 

sudo modprobe r8168
reboot

After I rebooted, things started working again as they did before. This process actually took me more than 3 hours to debug and solve so, there goes my morning 😅