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.

  • Latest r86168 driver (As of 15 June 2020)
  • linux-headers-<your kernel version> where your kernel version can be found with uname -a (ie: linux-headers-5.3.0-1026-gke)

Then install these packages using dpkg. And loa

Make your own Linux!

Building your own Linux OS from scratch is no dark magic, believe me! As long as you feel comfortable using a command line, it isn't such a daunting task, only requiring a fair amount of patience.

We'll be setting up an environment, compiling the kernel, userspace tools, a root filesystem and then test booting it. I'll assume you already run Linux on a machine, or in a Virtual Machine. Let's dive right in!


We'll first install the programs necessary for building. All these tools should be available in the major Linux distributions, but I'll only give the commands to install them on Debian/Ubuntu and Alpine Linux.

To compile the kernel, we need:

debian$ sudo apt install build-essential xz-utils libncurses5-dev bison flex bc perl libelf-dev libssl-dev  linux-headers-generic
alpine$ apk add apk add alpine-sdk xz ncurses-dev bison flex bc perl libelf-dev openssl-dev linux-headers findutils


First we have to fetch the source.

$ KERNEL_VERSION=linux-4.18.6
$ wget https://cdn.kernel