Realtek Ethernet card disconnnects randomly

8,010

Solution 1

A few days ago I found a new release of the driver (8.039.900) on Realtek's website. I downloaded, compiled and installed it, and never experienced any connection drops since.

Update r8168:

The most current driver source can be downloaded here.

Extract the downloaded archive and run

sudo make

in the extraction folder. After compilation, the currently installed r8168 module will be automatically replaced by the new version (which in my opinion should only happen when running make install)

To load the new version, run

sudo modprobe -r r8168 && sudo modprobe r8168

PS: Don't use the installation script which comes with this driver. It will uninstall the old module (no matter whether r8168 or r8169) before even attempting to compile the new one. If the compilation fails, you're left without internet, if you don't have WiFi or another Ethernet card.

Solution 2

N.B : This answer is by no means final. I've came up with a couple possible solutions based on some research online as well as personal suggestions from experience.

Replace Kernel Module

From researching online, it appears that frequently the best solution is to replace the r8168 module that comes with Ubuntu installation, with a newer , updated version. For instance, this crunchbang post.

This Ubuntu Forums post from 2012 documents a script for a newer, updated version of the r8168 module. You can do sudo apt-get install linux-headers-$(uname -r) or sudo apt-get install --reinstall linux-headers-$(uname -r) , and then follow matera.ttp's instructions. Praseonym, who also posted there, suggests installing the driver with dkms , which is supposed to rebuild modules for each kernel update. Now, you should have dkms already installed, and you could check it with which dkms . So you could either use Praseonym's instructions or matera.ttp's . The idea is the same.

Tweak Module Settings

For many network issues tweaking the module configurations could help solve the issues, but frankly I doubt it's an issue, since you've used r8169 with same effect. Nonetheless , give it a try.

In the /etc/modprobe.d/ directory, create r8168.conf file. In that file, write:

options eee_enable=1

Save and reboot.

Now, you could do very much same thing with other options. For instance, my first guess was to add options timer_count=3600 to the r8168.conf file. Why 3600 ? Assuming that the parameter deals with time, then it's most likely seconds.

I've found a case where it actually didn't work, and the problem was bios related. Refer to this page: http://ubuntuforums.org/showthread.php?t=2138125&page=2

If everything else fails

I've mentioned on other posts as well, that sometimes hardware is the issue and no matter how much tweaking you do - it won't help. In personal experience , I've dealt with two rtl8192 wireless chipsets, one of which was giving weird sound bug, but the other works almost flawlessly.

I suggest you explore possible replacements for your ethernet card. My suggestion would be portable usb hub with ethernet slot, much like these

Share:
8,010

Related videos on Youtube

s3lph
Author by

s3lph

Just some guy from Switzerland, fulltime Ubuntu/Mint ArchLinux user. Coding languages: Java (+Android), Python, C/C++, (PHP, CSS, HTML) My Devices: HP ProBook 455 G1, ArchLinux, AMD A8-4500M, 4x 1.9GHz, 8 GiB RAM, 256 GB SSD, 1TB HDD, AMD Radeon HD 8570M OnePlus 3T, LineageOS 14.1 I like offending people because I think people who get offended should be offended. - Linus Torvalds

Updated on September 18, 2022

Comments

  • s3lph
    s3lph over 1 year

    My laptop has a Realtek RTL8168 Ethernet card, which works pretty well. Except at some times, where the connection just gets dropped and I have to un- and replug the cable in order to reset the connection.

    I've tried the preinstalled r8169 module, but now I'm using the r8168 module built with the source from Realtek's website. The problem occurs with both driver modules.

    $ lspci | grep Ethernet
    01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
    
    $ dmesg
    #stops working, no reports
    #unplugging
    [ 9324.277753] r8168: eth0: link down
    [ 9328.636380] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
    #replugging
    [ 9334.316610] r8168: eth0: link up
    [ 9334.316744] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    #Working again
    

    PS: With grep NetworkManager /var/log/syslog, I've fould the following, around the time such a connection interruption happened:

    #EDIT:These messages are printed when I plug out the cable. Before, there is nothing
    Jan 28 23:40:31 dracarys NetworkManager[912]: <info> (eth0): carrier now OFF (device state 100, deferring action for 4 seconds)
    Jan 28 23:40:35 dracarys NetworkManager[912]: <info> (eth0): device state change: activated -> unavailable (reason 'carrier-changed') [100 20 40]
    Jan 28 23:40:35 dracarys NetworkManager[912]: <info> (eth0): deactivating device (reason 'carrier-changed') [40]
    Jan 28 23:40:35 dracarys NetworkManager[912]: <info> (eth0): canceled DHCP transaction, DHCP client pid 6975
    Jan 28 23:40:35 dracarys NetworkManager[912]: <warn> DNS: plugin dnsmasq update failed
    Jan 28 23:40:35 dracarys NetworkManager[912]: <info> Removing DNS information from /sbin/resolvconf
    Jan 28 23:40:35 dracarys NetworkManager[912]: <info> NetworkManager state is now DISCONNECTED
    #replug
    Jan 28 23:40:40 dracarys NetworkManager[912]: <info> (eth0): carrier now ON (device state 20)
    Jan 28 23:40:40 dracarys NetworkManager[912]: <info> (eth0): device state change: unavailable -> disconnected (reason 'carrier-changed') [20 30 40]
    Jan 28 23:40:40 dracarys NetworkManager[912]: <info> Auto-activating connection 'Wired connection 1'.
    Jan 28 23:40:40 dracarys NetworkManager[912]: <info> Activation (eth0) starting connection 'Wired connection 1'
    Jan 28 23:40:40 dracarys NetworkManager[912]: <info> (eth0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
    Jan 28 23:40:40 dracarys NetworkManager[912]: <info> NetworkManager state is now CONNECTING
    

    And then it worked again

    Any ideas on how to fix this? Let me know if you need additional information.

    EDIT: $ modinfo r8168

    filename:       /lib/modules/3.13.0-37-generic/kernel/drivers/net/ethernet/realtek/r8168.ko
    version:        8.038.00-NAPI
    license:        GPL
    description:    RealTek RTL-8168 Gigabit Ethernet driver
    author:         Realtek and the Linux r8168 crew <[email protected]>
    srcversion:     7600C3366E422907A1D79F1
    alias:          pci:v00001186d00004300sv00001186sd00004B10bc*sc*i*
    alias:          pci:v000010ECd00008168sv*sd*bc*sc*i*
    depends:        
    vermagic:       3.13.0-37-generic SMP mod_unload modversions 
    parm:           eee_enable:int
    parm:           speed:force phy operation. Deprecated by ethtool (8). (ushort)
    parm:           duplex:force phy operation. Deprecated by ethtool (8). (int)
    parm:           autoneg:force phy operation. Deprecated by ethtool (8). (int)
    parm:           aspm:Enable ASPM. (int)
    parm:           s5wol:Enable Shutdown Wake On Lan. (int)
    parm:           rx_copybreak:Copy breakpoint for copy-only-tiny-frames (int)
    parm:           timer_count:Timer Interrupt Interval. (int)
    parm:           debug:Debug verbosity level (0=none, ..., 16=all) (int)
    
    • Sergiy Kolodyazhnyy
      Sergiy Kolodyazhnyy over 9 years
      There is a command line utility systool, which is a part of sysfsutils package. It allows viewing with which parameters enabled/disabled the module is actually loaded during runtime. I'd suggest you download that, check what parameters are set for your r8168 module, and then play around with changing those options by adding them to /etc/modprobe/r8168.conf file. Among other things, instead of uplugging/replugging, restart the network-manager service with sudo service network-manager restart
    • Fabby
      Fabby over 9 years
      Seppi, I had an HP NW 9440 a few years back with the exact same problem and it turned out to be a wiring problem. (long story) Did you try another cable and/or visually inspecting (with a magnifying glass) the wires inside your port?
    • s3lph
      s3lph over 9 years
      @Serg The only parameter is eee_enable, which is not activated. How exactly would I enable it? (But I doubt it would change anything)
    • Sergiy Kolodyazhnyy
      Sergiy Kolodyazhnyy over 9 years
      @the_Seppi Well, eee_enable isnt the only thing I'd try to toggle. I'll post it in more details as an answer soon.
    • Sergiy Kolodyazhnyy
      Sergiy Kolodyazhnyy over 9 years
      By the way, is it a recent issue ? has it started after upgrading to a newer kernel ?
    • s3lph
      s3lph over 9 years
      No, this has been annoying me since I own this PC. But as I recently read, the RTL8168 has never been completely working with Linux.
    • s3lph
      s3lph almost 9 years
      Update: Seems to be a hardware problem.
  • s3lph
    s3lph over 9 years
    As I already mentioned in my question, I am already using r8168. So, unfortunately, your answer is useless to me.
  • mertyildiran
    mertyildiran over 9 years
    @the_Seppi I have the same chipset and I did this solution a few days ago. Previously my wireless was disconnecting but now it works well. I think this did the trick: echo “blacklist r8169″ >> /etc/modprobe.d/blacklist.conf
  • s3lph
    s3lph over 9 years
    I've done exactly the same when installing r8168. And back then I also blacklisted r8169. So basically, I've already applied your answer without success.
  • mertyildiran
    mertyildiran over 9 years
    @the_Seppi What is your laptop brand and model? I have experienced a similar issue on my Lenovo Flex 2.
  • s3lph
    s3lph over 9 years
    "do the [...] same thing with other options"? eee_enable is the only displayed parameter in systool -vm r8168. Btw. there's a new version of the driver (8.039). I'm currently compiling it and then we'll see whether it fixes things.
  • s3lph
    s3lph over 9 years
    It complains about your config file: libkmod: ERROR ../libkmod/libkmod-config.c:686 kmod_config_parse: /etc/modprobe.d/r8168.conf line 1: ignoring bad line starting with 'options'