Realtek RTL8111/8168/8411 Ethernet keeps dropping connection under load

Hi

I just switched my motherboard after the other one died but this is a different motherboard with a different Ethernet controller. I have internet connectivity but it is very flaky. It will drop under heavy load, eg, large downloads, youtube streaming, bittorrent but will work fine if i’m just browsing websites.
There is nothing wrong with my router or ISP connection as all my other devices work fine.

I have to uncheck then recheck enable networking in network manager or restart to get it working. sometimes it will restart on its own.

I’m not sure if it is a driver problem or some other issue but there is another thread about this chipset that had issues similar to mine
https://www.linuxquestions.org/questions/linux-hardware-18/realtek-rtl8111-8168-8411-ethernet-controller-r8168-driver-install-r8169-driver-doesn’t-work-4175641982/

they used to driver from the realtek site Realtek PCIe FE / GBE / 2.5G / Gaming Ethernet Family Controller Software - REALTEK
but that driver says it only support kernel upto 4.15 and im on fedora 30 on kernel 5.3.5 so I dont know if I should risk using it.

here is info for my device>
sudo lspci -v | grep -A 20 Ethernet
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
Subsystem: Micro-Star International Co., Ltd. [MSI] Device 7788
Flags: bus master, fast devsel, latency 0, IRQ 16
I/O ports at d000 [size=256]
Memory at f0004000 (64-bit, prefetchable) [size=4K]
Memory at f0000000 (64-bit, prefetchable) [size=16K]
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [70] Express Endpoint, MSI 01
Capabilities: [b0] MSI-X: Enable+ Count=4 Masked-
Capabilities: [d0] Vital Product Data
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel
Capabilities: [160] Device Serial Number 01-00-00-00-68-4c-e0-00
Kernel driver in use: r8169
Kernel modules: r8169

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether d4:3d:7e:19:4b:40 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.8/24 brd 192.168.0.255 scope global dynamic noprefixroute enp3s0
valid_lft 85011sec preferred_lft 85011sec
inet6 fd9c:6f93:d50b:0:9331:8cb:c18f:7ca5/64 scope global noprefixroute
valid_lft forever preferred_lft forever
inet6 2a02:c7f:1847:e500:826f:e7bc:c2bb:7d2c/64 scope global dynamic noprefixroute
valid_lft 3256sec preferred_lft 3256sec
inet6 fe80::bee6:9d82:c57c:2ea7/64 scope link noprefixroute
valid_lft forever preferred_lft forever

any help would be most welcome

Thanks

ok i fixed the problem, opensource r8168 driver is broke, used the closed source r8169 from the site linked in my prior post and it works fine, only issue is that blacklisting old driver will not work because it is loaded too early in boot process and the realtek install script will only rebuild init on debian/ubuntu so I had to run sudo dracut -f /boot/initramfs-5.3.5-200.fc30.x86_64.img

what I don’t know however is if when new kernels are automatically installed by dnf autoupdate if it will rebuild initramfs based on my current config or if I will manually have to run dracut everytime a new kernel is installed which will be a pain.

edit: r8169 is the open source broken driver and r8168 is the closed source working driver

I’m not 100% sure on this, but as far as I know your current config should be respected (i.e. blacklists from /etc/modprobe.d). Here’s (quite random) link resulting from a quick websearch:

I’d suggest doing some more research on a topic to confirm this. Though, of course, waiting for kernel update and verifying afterwards will work too. )) Or maybe someone else will confirm it here.


By the way, I have an

Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)

on my motherboard. Note revision difference though. It uses the same r8169 kernel module. I’ve never experienced the behavior you’re talking about. So it looks like the problem is between r8169 driver and your network card specifically, not the driver as a whole.

my fears were confirmed, dnf updated kernel to 5.3.6 today and low and behold the old broken r8169 driver is loaded. I had to run the realtek script again and run dracut again to get my internet back.

This is super annoying, I wonder if there is someway to tell dnf to run a script when it updates the kernel to automatically build the r8168 driver and run dracut because i’m at a loss on how to solve this issue.

@quasarenergy, have you tried blacklisting r8169 driver the way link I’ve posted suggests?

And yes, any kernel module you build yourself you’ll need to rebuild after each kernel update.

Well, as far as I know, both dkms and akmods systems do exactly that: rebuild kernel modules after new kernel is installed. I haven’t ever tried to set them up myself though, just used the already packaged versions.

I have blacklisted r8169 but to no avail, I havent a clue how the kernel update works but all I need to do is insert 3 lines into the update script wherever it is after its installed.

Well, there’s /etc/kernel/postinst.d/ with some scripts that already get run after kernel update. You can try to place your script there and see if it works. I can’t say what will happen if your script crashes or fails, wouldn’t it interfere with kernel update procedure. I think it shouldn’t – but I really don’t know.

Frankly I’m myself would just rebuild kernel module after kernel updates manually – so that I don’t interfere with the update process itself. Of course, you can do it any way you like.

You need to verify blacklist for r8169 is persistent and respected by dracut as well – so it won’t interfere in the future. After kernel update and first reboot you won’t have internet connectivity until you rebuild the module you need.

After rebuilding it you can just load it right away with sudo modprobe r8168 (assuming r8168 is the name of the module), and your connection should appear.

To check the module is actually loaded use lsmod | grep r8168.

For your system to load new module automatically you can create a file /etc/modules-load.d/r8168.conf containing one line with the name of the module (r8168). Actually build script for your module should have done it for you.

This way you shouldn’t need to rebuild dracut to load this module automatically on boot.

thanks for the info, the build script didn’t do the job but I have added r8168.conf and will investigate using /etc/kernel/postinst.d/