Realtek RTL8168/8111E and Ubuntu Linux

UPDATE: Stock kernel driver is fixed in Ubuntu 12.04 Precise Pangoling. Current kernel is 3.2.0-17-generic and everything has been working for quite some time.

If you are using Ubuntu (and probably other distributions too) and you have an on board Realtek RTL8168/8111E PCI Express network adapter you might find your network not working as it should. Slow connections or no connection at all and your logs full of messages like these:

Oct 02 09:13:25 machine kernel: r8169 0000:04:00.0: eth0: link up
Oct 02 12:45:17 machine kernel: r8169 0000:04:00.0: eth0: link up
Oct 02 12:45:20 machine kernel: r8169 0000:04:00.0: eth0: link up
Oct 02 13:15:12 machine kernel: r8169 0000:04:00.0: eth0: link up
Oct 02 13:15:13 machine kernel: r8169 0000:04:00.0: eth0: link up
Oct 02 13:22:13 machine kernel: r8169 0000:04:00.0: eth0: link up

Read on if you want to know why this happens and how to solve the problem.

Driver that is included in vanilla Linux kernel is actually a driver for a different network adapter, but works with 8111E too. Sort of works. Realtek made new official driver that fixes the problem, but disables the old driver. Which could be a problem for you if you have RTL8169/8110 and RTL8168/81111.

First you will need the latest driver for your network adapter. Get it here. You will have to extract it and compile it. Current version is 8.025.00.

$ tar -xvjf r8168-8.025.00.tar.bz2
$ cd r8168-8.025.00
$ make modules

If you are running Ubuntu 11.10 Oneiric Ocelot then you can ignore the README file and autorun.sh script. The script is broken and the information in the README is obsolete. For other distributions and kernels autorun.sh might work. When make is complete you will have to get rid of the old module and replace it with the new one. Do this, while you’re still in the r8168-8.025.00 directory.

$ cd src
$ sudo cp r8168.ko /lib/modules/`uname -r`/kernel/drivers/net/
$ sudo mv /lib/modules/`uname -r`/kernel/drivers/net/r8169.ko /lib/modules/`uname -r`/kernel/drivers/net/r8169.ko.old
$ sudo depmod -a

Now, all you need to do is to take care that the driver will load on boot.

$ sudo echo "r8168" >> /etc/modules

Wouldn’t it be wise to test if the new driver is working at all, before you reboot? Easier than eating pancakes!

$ sudo modprobe -r r8169 # At this point your network will stop working
$ sudo modprobe r8168 # And now network manager should pick up the new connection

Oh, and if you are annoyed that now your network interface is eth1 instead of eth0 as it used to be, remove the two lines from /etc/udev/rules.d/70-persistent-net.rules that end with NAME=”eth0″ and NAME=”eth1″.



Footnotes:
  1. I wasn’t able to test this, the new driver might support other network adapter too. []

  • You might want to check which module you are moving to .old and which one you are copying in. Filenames are the same in your example.

    Reply
  • thanks a lot!!!!!!

    Reply
  • On October 15, 2011 at 03:36 dirtyhabanero said:

    Great!

    Had a little trouble with `$ make module` and was getting a ‘src/Makelfile: No such file or directory’ error. Another old post suggested I just move the files in r8168-8.025.00/src folder straight into the /src folder.

    I then followed your method and everything is great. But is there a problem with moving files straight into /src?

    Reply
    • Hm, I tried it again and it works for me if I run make modules in the r8168 directory. Strange.

      If module compiled then everything is ok. :)

      Reply
    • I am having the same problem but my system is not allowing me to move the files manually. I do not have internet connection so I am simply running what came from the iso. How did carry out this manual copy and to where did you put the files? I am running Ubuntu 12.10.

      Reply
  • On October 21, 2011 at 13:08 Matt Goodall said:

    Thanks for writing this up. Worked perfectly for me.

    Reply
  • Thanks dude, after 2 days i got perfect drivers, thanks worked with my OS!!@Sara

    Reply
  • On November 6, 2011 at 17:56 Der Mol said:

    A warm thank-you and good karma to you for posting this!
    Fixed my problem big time (even though I’m using SuSE…) :)

    Reply
  • Thanks for that. I was going mad with my network randomly disconnecting.

    Reply
  • i tried your tutorial, it all works up to this point:

    sudo modprobe -r r8169
    FATAL: Module r8169 not found.

    I doubt that’s what it’s supposed to do, any tips?

    Reply
    • Try this:

      sudo lsmod | grep r81

      If you don’t see r8169 listed then you don’t have r8169 module loaded and you are probably not using RTL8168/9 network adapter.

      You can check this with:

      sudo lspci | grep Eth

      Reply
  • same here

    4g3nt-lnx ~ $ lsmod | grep r81*
    r8168 211483 0
    r8169 52788 0
    4g3nt-lnx ~ $ sudo modprobe -r r8169
    FATAL: Module r8169 not found.

    any idea?

    Reply
  • i also found this tutorial: http://unixblogger.wordpress.com/2011/10/18/the-pain-of-an-realtek-rtl8111rtl8168-ethernet-card/

    it helped me :) Its almost the same, but slightly different!

    It sure was a pain in bum to get this working!

    Reply
  • On December 1, 2011 at 16:55 Vitaliy said:

    Thanks!

    Reply
  • On December 15, 2011 at 12:47 claudio_otto said:

    Eres un grande!
    me funciono. luego de hacer sudo rmmod r8169. y repetir el proceso funciona correctamente!
    saludos

    Reply
  • Hi. thanks for the post. I had some trouble to get the Realtek working. The hint to remove the lines from /etc/udev/rules.d/70-persistent-net.rules did the trick for me.

    I use Ubuntu 11.04.

    Thanks again! Rick

    Reply
  • On January 23, 2012 at 13:00 sinister said:

    Looks like the Realtek driver contains binary blobs in files:

    – rtltool.c
    – r8186_n.c

    I don’t know if it would work without them (blobs), though.

    Reply
  • Thanks for this, was scratching my head at my abysmal network speeds.

    FWIW: autorun.sh ran successfully on vanilla ubuntu 10.4 using version r8168-8.027.00.

    Cheers!
    -Rock

    Reply
  • On February 6, 2012 at 01:19 Siddharth said:

    This worked just perfectly. I wasted more than 2 hours on this problem, trying atleast 10 different ways.

    Thank you so much BigWhale! I wish I could thank you more.

    Reply
  • On February 9, 2012 at 01:42 Diaa Sami said:

    For me It worked with the following modifications:
    1. Use rmmod to remove the module rather than modprobe -r.
    2. r8169 kept showing after restart until I did ‘sudo update-initramfs -u’

    Reply
  • Just wanted to say thanks. Brought my connection speed on Lubuntu 10.10 up from ~128kb/s to the 3MB/s I pay for

    Reply
  • the make script is buggy, make sure you are in a directory with no spaces in the name

    Reply
  • On March 20, 2012 at 03:30 Beardmancer said:

    Dang, this fix worked great for about a month. Now, I suddenly have the same problems again. lspci indicates that r8168 is loaded and r8169 is not, which is correct, right? Anybody have thoughts on what I could test?

    Reply
  • On March 26, 2012 at 20:47 Gregor said:

    Thank you man. Saved me alot of trouble.

    Reply
  • Man saved me from a lot of troubles!!!

    Thanks for this.

    Reply
  • All of this is not required anymore for Kubuntu 11.10 and r8168-8.029.00.tar.bz2 driver. All you have to do is this (tested on the fresh copy of the system):

    sudo -s
    apt-get install make gcc
    tar xvjf r8168-8.029.00.tar.bz2
    cd r8168-8.029.00/
    ./autorun.sh

    that is it, than you can check

    lspci -v | grep r8
    Kernel driver in use: r8168
    Kernel modules: r8168

    And the net works fine!

    Reply
  • Thank you! This post has surely saved me a lot of time.

    Reply
  • On September 13, 2012 at 07:31 inoekuma said:

    Hi, im currently running Ubuntu 12.04 LTS Precise. I’d gone many process even on your instruction given and others. but still my r8168 could not be detected. when i run the command

    lsmod | grep r81

    it will displayed this

    r8168 244911 0

    and when i run

    lspci | grep Eth

    only my build-in ethernet would displayed

    00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (rev 04)

    Someone please help me..sorry for my bad english

    Reply
  • Thanks very much for help us

    Reply
    • I don’t know why, but I followed the instructions but I cant get the driver load on Ubuntu 12, even after remove 8169 the card still loads 8169 instead of 8168.

      The script autorun.sh included in the package worked at last for me.

      Reply
  • I have ubuntu 12.10 installed with kernel 3.5.0-18-generic.

    I can confirm that this problem STILL EXISTS in this kernel.

    I have a stream of link up / link down messages.

    Reply
  • [...] Jan 2013: this driver issue was fixed in Ubuntu 12.04 / kernel 3.2.0-14 or [...]

    Reply