Installing NIC drivers in Linux

In this guide we install a NIC driver for a Realtek Gigabit Ethernet Card in a Linux Environment as it did not activate by default!

Installing NIC drivers in Linux
Standard NIC (Network Interface Card)

For unknown reasons Linux can be exceptionally good at automatically recognizing a plethora of devices. Plug it in - it works.  But sometimes it doesn't recognize a device.

In this instance we can see that we actually have no enabled Ethernet drvier:

1: lo  (Local loopback interface) typically is a 127.0.0.1
2. wlp3s0 (Wireless Lan)
3. docker0  Docker network virtual card for briding between your system and the docker virtual containers.

We can scan for the missing device with simply:

sudo lspci

We can see the missing device here:

01:00.3 Serial bus controller: NVIDIA Corporation TU116 USB Type-C UCSI Controller (rev a1)
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)
03:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8822CE 802.11ac PCIe Wireless Network Adapter

Clearly our Gigabit Ethernet Controller  is the one that needs a driver. After this point typically Realtek (and because they are such a HUGE part of the market we can use them as a defactoid nic installation guide:

We can see that one driver matches several instances of chips, namely RTL8111/8168/8411 will accept the same driver:

We can search for the closest module with:

sudo apt search rtl8 | grep r

A match comes up:

r8168-dkms/parrot6-updates,parrot6-updates,parrot6,parrot6,parrot6,parrot6,parrot6,parrot6,parrot6,parrot6 8.053.00-2parrot1 all [residual-config]
  dkms source for the r8168 network driver

We can install this with:

sudo apt-get install r8168-dkms -y

After this point we need to use modprobe. Modprobe is the way that Linux installs and adds a module from the Linux kernel which is required as NIC drivers are an embedded.

  • modules live under /lib/modules/{kernel} so to see your modules use:
uname -a

For this system reported:

Linux parrot 6.12.12-amd64

Next we can search with:

find /lib/modules/6.12-12-amd64/ -type f | grep rtl
  • At this point we can see that we have:
/lib/modules/6.12.12-amd64/updates/dkms/r8168.ko.xz

Which can be activated by its alias with:

sudo modprobe r8168

Once this is done you can see the new device as enp2s0:

You can take it down and back up with:

sudo ifconfig enp2s0 down && sudo ifconfig enp2s0 up

You can also add a ip address to it with:

sudo ip addr add 192.168.1.5/24 dev emp2s0
Linux Rocks Every Day