10

I am having a terrible week trying to resolve an issue with my ethernet connection. The ethernet works fine for 1 minute before I lose connection. The networks icon to the top constantly reads as connected, but I have to disconnect and reconnect by clicking "Wired connection 1" for a few seconds/mins of connection.

To work around this issue, I have a cron job running every minute to disconnect and reconnect with the following lines of code:

#!/bin/bash
sudo ifdown enp4s0
sudo ifup enp4s0

Please help. I need a more permanent solution for a steady ethernet connection.

lspci | grep -i realtek

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

lsmod | grep r816

r8168                 499712  0

dmesg | grep r816
    [    2.207551] r8168: loading out-of-tree module taints kernel.
    [    2.207789] r8168: module verification failed: signature and/or required key missing - tainting kernel
    [    2.208146] r8168 Gigabit Ethernet driver 8.044.02-NAPI loaded
    [    2.208243] r8168 0000:04:00.0: Default use INTx.
    [    2.230190] r8168: This product is covered by one or more of the following patents: US6,570,884, US6,115,776, and US6,327,625.
    [    2.230194] r8168  Copyright (C) 2017  Realtek NIC software team <nicfae@realtek.com> 
    [    2.305436] r8168 0000:04:00.0 enp4s0: renamed from eth0
    [   23.483150] r8168: enp4s0: link up
    [  866.740512] r8168: enp4s0: link up
    [71714.965195] r8168: enp4s0: link up
    [71773.494292] r8168: enp4s0: link up

sudo ethtool enp4s0

Settings for enp4s0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Speed: Unknown!
    Duplex: Half
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown
    Supports Wake-on: pumbg
    Wake-on: ug
    Current message level: 0x00000033 (51)
                   drv probe ifdown ifup
    Link detected: no



ifconfig
enp4s0    Link encap:Ethernet  HWaddr 00:26:18:11:78:a8  
          inet addr:192.168.26.30  Bcast:192.168.27.255  Mask:255.255.254.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:394947 errors:0 dropped:0 overruns:0 frame:0
          TX packets:278710 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:270000748 (270.0 MB)  TX bytes:37833932 (37.8 MB)
          Interrupt:18 Base address:0xa000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:38302 errors:0 dropped:0 overruns:0 frame:0
          TX packets:38302 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:3045435 (3.0 MB)  TX bytes:3045435 (3.0 MB)

lshw

*-network
                description: Ethernet interface
                product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
                vendor: Realtek Semiconductor Co., Ltd.
                physical id: 0
                bus info: pci@0000:04:00.0
                logical name: enp4s0
                version: 01
                serial: 00:26:18:11:78:a8
                size: 1Gbit/s
                capacity: 1Gbit/s
                width: 64 bits
                clock: 33MHz
                capabilities: bus_master cap_list rom ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
                configuration: autonegotiation=on broadcast=yes driver=r8168 driverversion=8.044.02-NAPI duplex=full latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
                resources: irq:18 ioport:d800(size=256) memory:f9fff000-f9ffffff memory:f9fc0000-f9fdffff

cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo 
iface lo inet loopback



# The primary network interface
auto enp4s0
allow-hotplug enp4s0
iface enp4s0 inet dhcp

pre-up ifconfig enp4s0 hw ether 00:26:18:11:78:A8

cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=true

uname -r
4.8.0-58-generic

Things I've done:

1) Install the r8168-dkms using Synaptic.
2) Set the IPv6 settings "Method" section to "ignore".
3) Changed my Internet DNS servers to 8.8.8.8,8.8.4.4...etc.
4) Change the "MTU" to 9000.
5) Changed interface file to: auto lo iface lo inet loopback auto enp4s0 iface enp4s0 inet dhcp

as well as for static.
6) sudo apt-get purge r8168-dkms from Ubuntu 14.04 wired connection keep disconnecting
7) Everything on https://unixblogger.com/2011/10/18/the-pain-of-an-realtek-rtl8111rtl8168-ethernet-card/
8) Install older version of r8168, then:

sudo update-initramfs -u 
echo "blacklist r8169" | sudo tee -a /etc/modprobe.d/blacklist.conf

9) Read through pages of https://ubuntuforums dot org/archive/index.php/t-2291730.html
10) Everything on https: //ubuntuforums dot org/showthread.php?t=2248047
11) Cold booting.
12)

sudo sh -c "echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo sh -c "echo 'net.ipv6.conf.default.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo sh -c "echo 'net.ipv6.conf.lo.disable_ipv6 = 1' >> /etc/sysctl.conf"
sudo sysctl -p
sudo sed -i 's/false/true/g' /etc/NetworkManager/NetworkManager.conf
sudo reboot -i NOW

13) https: //nosemaj dot org/hardy-r8168
14) Test ethernet cable with other devices.
15) Crying.
16) Asked my mom.

UPDATE #1

dkms status
bbswitch, 0.8, 4.8.0-36-generic, x86_64: installed
bbswitch, 0.8, 4.8.0-58-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-36-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-58-generic, x86_64: installed
r8168, 8.041.00: added

modinfo r8168 | grep -i version
version:        8.044.02-NAPI
srcversion:     5388F61A23A68A548D001CF
vermagic:       4.8.0-58-generic SMP mod_unload modversions 

sudo apt-get purge r8168-dkms
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  r8168-dkms*
0 upgraded, 0 newly installed, 1 to remove and 13 not upgraded.
After this operation, 1,109 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 243432 files and directories currently installed.)
Removing r8168-dkms (8.041.00-1) ...

------------------------------
Deleting module version: 8.041.00
completely from the DKMS tree.
------------------------------
Done.
Purging configuration files for r8168-dkms (8.041.00-1) ...

Commands to remove:

sudo apt-get remove r8168-dkms
sudo apt-get purge r8168-dkms
sudo /sbin/modprobe -r r8168

None of these commands removed 8.044.

UPDATE #2

dkms status
bbswitch, 0.8, 4.8.0-36-generic, x86_64: installed
bbswitch, 0.8, 4.8.0-58-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-36-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-58-generic, x86_64: installed
r8168, 8.041.00: added

sudo dkms build r8168/8.041.00 -k "$(uname -r)/$(uname -p)"

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area....
make KERNELRELEASE=4.8.0-58-generic -C /lib/modules/4.8.0-58-generic/build M=/var/lib/dkms/r8168/8.041.00/build....(bad exit status: 2)
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/r8168-dkms.0.crash'
Error! Bad return status for module build on kernel: 4.8.0-58-generic (x86_64)
Consult /var/lib/dkms/r8168/8.041.00/build/make.log for more information.

cat /var/lib/dkms/r8168/8.041.00/build/make.log

DKMS make.log for r8168-8.041.00 for kernel 4.8.0-58-generic (x86_64)
Tue Jul 11 16:03:35 AST 2017
make: Entering directory '/usr/src/linux-headers-4.8.0-58-generic'
  LD      /var/lib/dkms/r8168/8.041.00/build/built-in.o
  CC [M]  /var/lib/dkms/r8168/8.041.00/build/r8168_n.o
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c: In function ‘rtl8168_fix_features’:
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c:4212:30: error: ‘NETIF_F_ALL_CSUM’ undeclared (first use in this function)
                 features &= ~NETIF_F_ALL_CSUM;
                              ^
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c:4212:30: note: each undeclared identifier is reported only once for each function it appears in
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c: In function ‘rtl8168_start_xmit’:
/var/lib/dkms/r8168/8.041.00/build/r8168_n.c:24599:12: error: ‘struct net_device’ has no member named ‘trans_start’
         dev->trans_start = jiffies;
            ^
scripts/Makefile.build:289: recipe for target '/var/lib/dkms/r8168/8.041.00/build/r8168_n.o' failed
make[1]: *** [/var/lib/dkms/r8168/8.041.00/build/r8168_n.o] Error 1
Makefile:1491: recipe for target '_module_/var/lib/dkms/r8168/8.041.00/build' failed
make: *** [_module_/var/lib/dkms/r8168/8.041.00/build] Error 2
make: Leaving directory '/usr/src/linux-headers-4.8.0-58-generic'

UPDATE #3

After trying and failing with r8168 V 8.042... I tried version 8.043.02 and had some sort of success, although we're not at the final solution yet.

sudo dkms build r8168/8.043.02 -k "$(uname -r)/$(uname -p)"
Module r8168/8.043.02 already built for kernel 4.8.0-58-generic/4

sudo dkms install r8168/8.043.02 -k "$(uname -r)/$(uname -p)"
Module r8168/8.043.02 already installed on kernel 4.8.0-58-generic/x86_64

dkms status
bbswitch, 0.8, 4.8.0-58-generic, x86_64: installed
nvidia-375, 375.66, 4.8.0-58-generic, x86_64: installed
r8168, 8.043.02, 4.8.0-58-generic, x86_64: installed (WARNING! Diff between built and installed module!)

UPDATE #4

ls -al /var/lib/dkms/r8168
total 12
drwxr-xr-x 3 root root 4096 Jul 11 16:43 .
drwxr-xr-x 5 root root 4096 Jul 11 16:42 ..
drwxr-xr-x 4 root root 4096 Jul 11 16:43 8.043.02
lrwxrwxrwx 1 root root   32 Jul 11 16:43 kernel-4.8.0-58-generic-x86_64 -> 8.043.02/4.8.0-58-generic/x86_64

modinfo r8168 | grep -i version
version:        8.044.02-NAPI
srcversion:     5388F61A23A68A548D001CF
vermagic:       4.8.0-58-generic SMP mod_unload modversions 


ls -al /lib/modules/4.8.0-58-generic/updates/dkms
total 18624
drwxr-xr-x 2 root root     4096 Jul  1 11:01 .
drwxr-xr-x 3 root root     4096 Jul  1 11:00 ..
-rw-r--r-- 1 root root    22720 Jul  1 11:00 bbswitch.ko
-rw-r--r-- 1 root root    85488 Jul  1 11:01 nvidia_375_drm.ko
-rw-r--r-- 1 root root 16735368 Jul  1 11:01 nvidia_375.ko
-rw-r--r-- 1 root root  1086360 Jul  1 11:01 nvidia_375_modeset.ko
-rw-r--r-- 1 root root  1124728 Jul  1 11:01 nvidia_375_uvm.ko

modinfo /lib/modules/4.8.0-58-generic/updates/dkms/r8168.ko
modinfo: ERROR: Module /lib/modules/4.8.0-58-generic/updates/dkms/r8168.ko not found.

UPDATE 5

It seems as though this command removed the 8.044 driver and now all that's left is the 8.043.02 driver.

sudo apt-get -y dist-upgrade
  • 1
    You really do need the r8168-dkms. Reinstall it, and remove all of the changes that you made... like MTU=9000, etc. Please describe your network configuration. Where does the network cable from the computer go? Switch/router/modem? – heynnema Jul 07 '17 at 23:08

1 Answers1

7

From the comments...

  1. you really do need to run r8168-dkms in your configuration

  2. undo all of the changes that you've made... they didn't fix the problem, only created new ones

  3. After closer review, I see that you're using the r8168-dkms (8.044.02-NAPI) for Ubuntu 17.10 (on a 16.04 system). Please install the correct version and retest.

  4. In your Network GUI, you have multiple "Wired Connection" profiles set up. They would be named Wired Connection, Wired Connection 1, Wired Connection 2, etc. Delete all except for Wired Connection.

Update #1:

Assuming that the current status is that dkms status shows r8168, 8.041.00 : added...

sudo dkms build r8168/8.041.00 -k "$(uname -r)/$(uname -p)"
sudo dkms install r8168/8.041.00 -k "$(uname -r)/$(uname -p)"

Note: you may have to confirm the correct values of r8168/8.041.00 (module/version) by either looking in /usr/src or /var/lib/dkms/r8168.

dkms status

Should show r8168, 8.041.0 installed.

reboot
modinfo r8168 | grep -i version

Should say 8.041.00.

Update #2:

  • r8168 v8.041.00 was too old for 16.04.2 (kernel 4.8.0-58)
  • we're now using r8168 v8.043.02

Update #3:

We'll completely remove r8168-dkms and un-blacklist r8169 and then reinstall r8168-dkms from the Ubuntu repos.

  • sudo dkms remove r8168/8.043.02 -k "$(uname -r)/$(uname -p)"
  • sudo apt-get purge r8168-dkms
  • cd /var/lib/dkms
  • ls -al
    • should not show r8168
  • cd /usr/src
  • ls -al
    • should not show r8168.043.02
  • find /lib -name r8168.ko
    • should not show r8168.ko
  • cd /etc/modprobe.d
  • ls -al r8168*
    • should show no files
  • grep -i r816 *
    • edit output of grep into question as update #n
  • cd
  • sudo modprobe -r r8168
  • sudo update-initramfs -u -k "$(uname -r)"
  • stop here, ping me at @heynnema
heynnema
  • 70,711
  • Sorry for the late reply. Thanks for reading through my problem.

    I undid all changes. I have 8.041.01 deb file. However, I can't switch the drivers. I purged / removed all r8168 drivers, re-installed the deb file, but whenever I check, it is still version 8.044.02. I don't know how to tell it to use the older version.

    – Gpu Center Jul 11 '17 at 18:58
  • @GpuCenter If you purged the newer version, it should be gone. What command did you use? Edit your question to include dkms status and modinfo r8168 | grep -i version. Start new comments to me with @heynnema or I may miss them. – heynnema Jul 11 '17 at 19:08
  • @heynnema I have no ethernet connection on that system so I had to move to laptop. Commands to remove: sudo apt-get remove r8168-dkms, sudo apt-get purge r8168-dkms, sudo /sbin/modprobe -r r8168. All of the removal commands remove version 8.041. When I type modinfo r8168, the same version 8.044 exists. Under dkms status, r8168, 8.041.00: added. This however no longer exists after the remove / purge. Version 8.044.02 -NAPI still exists. – Sterls Jul 11 '17 at 19:30
  • @GpuCenter Do update #1 – heynnema Jul 11 '17 at 19:45
  • @heynnema updated. – Gpu Center Jul 11 '17 at 19:54
  • @GpuCenter you didn't follow my instructions. They were written with the last known dkms status showing as added. Now dkms status should not show r8168 at all. Reinstall the 8.041 .deb file, and then redo the dkms status... if it shows r8168 8.041 as added again, do my update #1 again. – heynnema Jul 11 '17 at 19:58
  • @heynnema sorry, I posted my update #1 before executing your instructions. I received an error on line one, as shown in my update #2. Thanks for spending your time to help me. I really appreciate it! – Gpu Center Jul 11 '17 at 20:16
  • 1
    @GpuCenter ah... you must be running 16.04.2. That has a newer kernel than 16.04, so you'll need a newer r8168. Purge r8168-dkms again. Are you installing r8168-dkms from the Ubuntu repos, or from a downloaded .deb file? Download .042 and retry. If that doesn't give dkms status as installed, we may have to go to .043. – heynnema Jul 11 '17 at 20:24
  • @heynnema you are right. I tried version 8.043.02 to some success. Although after the reboot, dkms status is displayed in update #3. I did some googling and someone said to remove the entire dkms and then reinstall it. What do you think? – Gpu Center Jul 11 '17 at 21:02
  • @GpuCenter we're close. Do sudo modprobe -r r8168 then sudo modprobe r8168 then reboot then dkms status. – heynnema Jul 11 '17 at 21:10
  • @heynnema sadly, no change. I did some more digging and I can't find anything. It is quite frustrating. Even after the sudo modprobe -r r8168 when I check the modinfo nothing changes. I did your suggestion twice and thus rebooted twice but still no change. – Gpu Center Jul 11 '17 at 21:37
  • @GpuCenter It's a small problem that we're trying to solve right now. There's just the right sequence of commands to solve it though. But because of the number of times you've tried to do this, there's some leftovers. Show me ls -al /var/lib/dkms/r8168 and modinfo r8168 | grep -i version. – heynnema Jul 11 '17 at 21:53
  • @GpuCenter ps: also show me ls -al /lib/modules/4.8.0-58-generic/updates/dkms – heynnema Jul 11 '17 at 22:09
  • @GpuCenter ps2: and modinfo /lib/modules/4.8.0-58-generic/updates/dkms/r8168.ko – heynnema Jul 11 '17 at 22:26
  • @heynnema see update 4 for the information you requested. – Gpu Center Jul 12 '17 at 16:37
  • Where did you get the r8168-dkms for version .043? What version does your Synaptic indicate? The r8168 built module is not making it to the proper directory. And, in your update #3 indicated that the module had already been built... which it shouldn't have been. If you're willing to stick with it, I'll probably have you remove r8168-dkms, we'll make sure all the parts are really gone, and we'll start over. Let me know how you feel. – heynnema Jul 12 '17 at 19:00
  • @heynnema I downloaded it from https://packages.ubuntu.com/zesty/r8168-dkms But I found another at https://r8168dl.appspot.com which I'll try next.

    I will stick with it. Can you suggest a way for me to completely remove it? Even after I purge / remove r8168 as well as network manager, version 8.044 persists. Previously when I tried, commands to remove it only removed 8.041, not 8.044. Do I have to navigate to the root files and delete it specifically? Synaptic currently indicates 8.043.02 as the installed and latest version.

    – Gpu Center Jul 13 '17 at 15:13
  • Don't use the one from appspot.com. Use the one from the Ubuntu repos. First we need to fully remove the currently installed r8168-dkms, edit some files in /etc/modprobe.d, and make sure that the r8169 kernel module loads again. Give me a few minutes to write an update to my answer. – heynnema Jul 13 '17 at 16:07
  • @heynnema I solved it using the line in Update 5. I was trying to do something unrelated and I noticed that command cleaned the 8.044 driver out of the system. I'm not sure what that command is supposed to achieve, but it solved my problem. Thank you for the days you've spent helping me. That command would not have worked had I still been trying with 8.041. – Gpu Center Aug 10 '17 at 20:36
  • Is there an abbreviated version of this answer, for what to do if you haven't yet done all the things the OP did that made things worse? – James_pic May 02 '18 at 22:37
  • @James_pic if this answer doesn't help with your specific situation, please just ask a new question, and we'll try to help. – heynnema May 03 '18 at 00:33
  • @heynnema referred someone here. Please read and leave a comment if you think my hunch is correct... (and then add a CV off course!) ;-) – Fabby Nov 30 '18 at 20:07