🛻Installing the r8168 driver的正确方法 PVE Debian
| 2023-7-5
0  |  0 分钟
Jul 5, 2023 05:29 AM
Fix driver problems with Realtek NICs by installing r8168.


The Linux r8169 driver for the Realtek network chips does not always work correctly up to kernel version 4.16. There can be timeouts and/or frequent link up/link down state changes, bandwidth problems and even system crashes may occur.
One solution is to use the official Realtek r8168 driver (instead of r8169). It can be installed from external repositories or compiled by yourself. As an alternative, you can upgrade the kernel to version 4.17+.
This article describes how to setup the network driver.
ssh 偶尔卡顿一下

Option A - Installing kmod-r8168 from elrepo.org

ELRepo is an RPM repository for Enterprise Linux packages. ELRepo supports Red Hat Enterprise Linux and its derivatives (CentOS, Scientific Linux and others). It is the easiest way to get the r8168 driver for the standard upstream kernels.
NOTE: If you are using a special kernel like Virtuozzo, OpenVZ or something similar you MUST compile the module yourself!
Import the public key:
rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org
Install ELRepo for RHEL 6, CentOS 6 or SL 6:
rpm -Uhv http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
For RHEL 7, CentOS 7 or SL 7:
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
Install the kmod-r8168 Realtek r8168 driver:
yum --enablerepo=elrepo install kmod-r8168
After a reboot of the server the new driver will be used. It stays active even after kernel upgrades.

Option B - Installation from source

Step 1 - Prerequisites

Please make sure you are running the latest kernel available by running yum or apt-get and then rebooting.


On CentOS the header packages of the kernel, kernel-devel and kernel-headers, as well as the compiler, will need to be installed to replace the driver:
yum install gcc gcc-c++ kernel-devel kernel-headers


In Debian/Ubuntu the name of the header package depends on the selected kernel. It can be for example linux-headers-generic or linux-headers-server. All the other required packages will be installed via build-essentials:
aptitude install build-essential linux-headers-`uname -r`


In Proxmox the headers can be found in the pve-headers package
aptitude install pve-headers-`uname -r`

Step 2 - Getting the sources

Step 3 - Compiling the driver

The package contains an autorun.sh script that automatically compiles the drivers and replaces the present r8169 driver. Doing so means the network connection is lost. You should therefore start this script in a screen session and only use it if you are absolutely sure that the kernel module can be compiled without errors. You can check this beforehand through make modules.
make all
If there are no errors with make modules, you can replace the driver in the current system. In this case the network connection is interrupted and the r8169 driver permanently disabled!
If you do not want an interruption of the system or you want to only temporarily disable the r8169 driver, you can instead compile the driver as shown below.

Step 4 - Activating the new driver


In the file /etc/modprobe.conf the appropriate driver for eth0 needs to be edited. To do this the line
alias eth0 r8169
must be changed to
alias eth0 r8168
The new driver must now be activated. To do this a simple shell script can be created that does the necessary steps.
Execute that script:
sh /tmp/r8168
After several seconds the server should be back online using the new network driver. The working directory can now be removed:
rm -rf /root/r8168


After installing the driver, update the module dependencies.
depmod -a
First the r8169 network driver needs to be blocked, so as to prevent the kernel from loading it. Note: If additional NICs are installed in the server, the driver must not be blocked.
Ubuntu/Debian 6.0 (Squeeze):
echo "blacklist r8169" >> /etc/modprobe.d/blacklist.conf
Next, the kernel must be forced to include the driver in the initrd. This also ensures that if additional NICs have been installed the new r8168 module is loaded before the r8169 module.
echo "r8168" >> /etc/initramfs-tools/modules
Afterwards the initrd will be rebuilt.
update-initramfs -v -t -u
Now you can reboot the server.
After a kernel update the driver might need to be recompiled.


Either of the two ways shown here should eliminate the problems with the Realtek network chip.


  • 操作系统
  • PVE
  • ProxmoxVE 虚拟机导入导出看网卡信息方法: - 折腾 PVE RLT 8168 网卡驱动