Wired connection drops and reconnects randomly several times per day

Hi,

My desktop with Manjaro and Gnome 40 randomly disconnects from the wired network and then reconnects. As I work on this computer all day, every day, this is quite annoying, also because I am often connected with a VPN and every time it disconnects, it also breaks the tunnel.

Weirdly (or perhaps not) enough I had the same problem with my laptop connected to the same network: see Wired connection continously connects and disconnects

With my laptop I solved the problem by using a different kernel module: r8168 instead of r8169. I am doing the same with my desktop, but it does not work.

~
9:05:28 ⟩ sudo dmesg | grep r8168
[    2.898331] r8168: loading out-of-tree module taints kernel.
[    2.939386] r8168: module verification failed: signature and/or required key missing - tainting kernel
[    2.942964] r8168 Gigabit Ethernet driver 8.049.02-NAPI loaded
[    2.942983] r8168 0000:03:00.0: enabling device (0000 -> 0003)
[    2.942991] r8168 0000:03:00.0: can't find IRQ for PCI INT A; please try using pci=biosirq
[    2.959608] r8168: This product is covered by one or more of the following patents: US6,570,884, US6,115,776, and US6,327,625.
[    2.961639] r8168  Copyright (C) 2021 Realtek NIC software team <nicfae@realtek.com> 
[    3.060475] r8168 0000:03:00.0 enp3s0: renamed from eth0
[    6.301645] r8168: enp3s0: link up
[ 3978.578097] r8168: enp3s0: link down
[ 3990.781175] r8168: enp3s0: link up
[ 4136.711160] r8168: enp3s0: link down
[ 4148.914286] r8168: enp3s0: link up

You can see the entries in dmesg where it says link down/link up, is when this happens.
I looked a bit around some time ago trying to solve this, and at a certain point I though it had to do with the promise (not really sure what that is), but right now I don’t remember where I found that info.

My inxi is

~
9:13:17 ⟩ inxi -Fxzc0
System:    Kernel: 5.12.19-1-MANJARO x86_64 bits: 64 compiler: gcc v: 11.1.0 Desktop: GNOME 40.3 Distro: Manjaro Linux 
           base: Arch Linux 
Machine:   Type: Desktop Mobo: ASRock model: X300M-STX serial: <filter> UEFI: American Megatrends v: P1.40 date: 08/04/2020 
Battery:   Device-1: hidpp_battery_0 model: Logitech G603 Wireless Gaming Mouse charge: 100% (should be ignored) 
           status: Discharging 
CPU:       Info: 8-Core model: AMD Ryzen 7 PRO 4750G with Radeon Graphics bits: 64 type: MT MCP arch: Zen 2 rev: 1 cache: 
           L2: 4 MiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 115039 
           Speed: 2994 MHz min/max: 1400/3600 MHz boost: enabled Core speeds (MHz): 1: 2994 2: 1380 3: 1391 4: 1346 5: 3041 
           6: 1339 7: 3019 8: 1330 9: 1377 10: 1353 11: 1397 12: 1397 13: 1671 14: 1372 15: 1512 16: 1397 
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Renoir driver: amdgpu v: kernel bus-ID: 04:00.0 
           Device-2: Logitech HD Webcam C525 type: USB driver: snd-usb-audio,uvcvideo bus-ID: 3-2.2:5 
           Display: x11 server: X.org 1.20.13 driver: loaded: amdgpu,ati unloaded: modesetting resolution: <missing: xdpyinfo> 
           Message: Unable to show advanced data. Required tool glxinfo missing. 
Audio:     Device-1: Advanced Micro Devices [AMD/ATI] driver: snd_hda_intel v: kernel bus-ID: 04:00.1 
           Device-2: Advanced Micro Devices [AMD] Family 17h HD Audio vendor: ASRock driver: snd_hda_intel v: kernel 
           bus-ID: 04:00.6 
           Device-3: Logitech HD Webcam C525 type: USB driver: snd-usb-audio,uvcvideo bus-ID: 3-2.2:5 
           Sound Server-1: ALSA v: k5.12.19-1-MANJARO running: yes 
           Sound Server-2: JACK v: 1.9.19 running: no 
           Sound Server-3: PulseAudio v: 15.0 running: yes 
           Sound Server-4: PipeWire v: 0.3.33 running: yes 
Network:   Device-1: Intel Dual Band Wireless-AC 3168NGW [Stone Peak] driver: iwlwifi v: kernel bus-ID: 02:00.0 
           IF: wlp2s0 state: down mac: <filter> 
           Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: ASRock driver: r8168 v: 8.049.02-NAPI 
           port: f000 bus-ID: 03:00.0 
           IF: enp3s0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
           IF-ID-1: vpn0 state: down mac: N/A 
Bluetooth: Device-1: Intel Wireless-AC 3168 Bluetooth type: USB driver: btusb v: 0.8 bus-ID: 3-2.1:4 
           Report: bt-adapter ID: hci0 rfk-id: 1 state: down bt-service: enabled,running rfk-block: hardware: no software: yes 
           address: <filter> 
Drives:    Local Storage: total: 238.47 GiB used: 76.42 GiB (32.0%) 
           ID-1: /dev/nvme0n1 vendor: Toshiba model: THNSN5256GPUK NVMe 256GB size: 238.47 GiB temp: 50.9 C 
Partition: ID-1: / size: 237.97 GiB used: 76.42 GiB (32.1%) fs: btrfs dev: /dev/nvme0n1p2 
           ID-2: /boot/efi size: 511 MiB used: 576 KiB (0.1%) fs: vfat dev: /dev/nvme0n1p1 
Swap:      Alert: No swap data was found. 
Sensors:   System Temperatures: cpu: 42.9 C mobo: N/A gpu: amdgpu temp: 32.0 C 
           Fan Speeds (RPM): fan-1: 0 fan-2: 1151 fan-3: 0 fan-4: 0 fan-5: 0 
Info:      Processes: 397 Uptime: 1h 24m Memory: 13.62 GiB used: 4.73 GiB (34.8%) Init: systemd Compilers: gcc: 11.1.0 
           clang: 12.0.1 Packages: 1231 Shell: Zsh v: 5.8 inxi: 3.3.06 

I should mention that I do not have access to the router as I live in a academic residence, where essentially I can either connect to the wifi (where I did not notice any problem with random disconnections/reconnections, however I have not tested it properly), or I can simply connect to the (only) ethernet socket available, which just works out of the box (besides this issue I am having with the random disconnections).

Remove it, blacklist it if required, and use the default r8169 from the kernel.
Disable IPv6 and mac address randomization too. Restart your device + router after that and see how it goes.

Removed it and disabled IPv6.
I don’t know what mac address randomization is and how to disable it (I don’t know if I have enabled it in the first place). I am using Gnome and the network manager.
I restarted my device but I don’t have the option to restart the router as the only thing I have is the ethernet socket.

I will monitor how it goes this week and come back by the end of the week with some news.

Thanks.

End of the week update: the problem subsists.

~
10:05:35 ⟩ sudo dmesg | grep r8169
[sudo] password for stefano: 
[    2.984978] r8169 0000:03:00.0: enabling device (0000 -> 0003)
[    2.984988] r8169 0000:03:00.0: can't find IRQ for PCI INT A; please try using pci=biosirq
[    3.003796] libphy: r8169: probed
[    3.003934] r8169 0000:03:00.0 eth0: RTL8168h/8111h, a8:a1:59:4e:ed:3a, XID 541, IRQ 48
[    3.003936] r8169 0000:03:00.0 eth0: jumbo features [frames: 9194 bytes, tx checksumming: ko]
[    3.294343] r8169 0000:03:00.0 enp3s0: renamed from eth0
[    3.405300] Generic FE-GE Realtek PHY r8169-300:00: attached PHY driver (mii_bus:phy_addr=r8169-300:00, irq=MAC)
[    3.565382] r8169 0000:03:00.0 enp3s0: Link is Down
[    7.154924] r8169 0000:03:00.0 enp3s0: Link is Up - 1Gbps/Full - flow control rx/tx
[  936.597785] r8169 0000:03:00.0 enp3s0: Link is Down
[  941.020465] r8169 0000:03:00.0 enp3s0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 2077.515941] r8169 0000:03:00.0 enp3s0: Link is Down
[ 2081.933994] r8169 0000:03:00.0 enp3s0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 2998.731165] r8169 0000:03:00.0 enp3s0: Link is Down
[ 3002.335293] r8169 0000:03:00.0 enp3s0: Link is Up - 1Gbps/Full - flow control rx/tx

Already happened four times in the space of 1 hour.
I do have new info though, for two consecutive days, after disconnecting and reconnecting several times like shown above, the speed (auto) negotiated was decreased to 100Mbps, and, after that, the disconnections did not happen anymore. I don’t know if that is coincidence, or perhaps there is some faulty cable somewhere and that is the reason for it all.
As I said in the previous posts, I don’t really have control over that, as I simply have an ethernet socket in the wall, and I use a cat6 ethernet cable (1-meter long) plugged to my desktop.

~
10:53:50 ⟩ sudo ethtool enp3s0
[sudo] password for stefano: 
Settings for enp3s0:
	Supported ports: [ TP	 MII ]
	Supported link modes:   10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Full
	Supported pause frame use: Symmetric Receive-only
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Full
	Advertised pause frame use: Symmetric Receive-only
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Link partner advertised link modes:  10baseT/Half 10baseT/Full
	                                     100baseT/Half 100baseT/Full
	                                     1000baseT/Full
	Link partner advertised pause frame use: Symmetric
	Link partner advertised auto-negotiation: Yes
	Link partner advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Auto-negotiation: on
	master-slave cfg: preferred slave
	master-slave status: master
	Port: Twisted Pair
	PHYAD: 0
	Transceiver: external
	MDI-X: Unknown
	Supports Wake-on: pumbg
	Wake-on: d
	Link detected: yes

Perhaps I can try to manually set the speed to 100Mbps and see if this solves the problem? However, from the GNOME NetworkManager interface there is no such option available.

I can confirm that if I set the speed to 100 Mbit/s, I do not have these random disconnections anymore. This week, essentially every morning when turning on the desktop I was running this command

sudo ethtool -s enp3s0 speed 100 duplex full autoneg off

and every time, after the command was issued, I did not see any disconnection until night, when I was turning off the pc.
Now, this seems to solve the problem, however I am obviously unhappy to restrict my internet connection and would ideally like to go back to 1000Mbit/s. Does somebody have any idea on what is the cause for this?