The pain of an Realtek (RTL8111/RTL8168) ethernet card

WARNING: This post is really old and it happens that it doesn’t work with newer Kernels ( >= 4.0). You should check out my new article if you want to install the driver for your RTL8111/RTL8168. You can check out the new article here: Click me (updated guide).

The most of the Realtek ethernet cards are working out of the box on a Linux machine. But some of them, for e. g. the RTL8111/RTL8168, making some troubles.

In the last three Ubuntu Versions (11.10, 11.04 and 10.10) and the latest Debian testing, you will have the problem, that the noticed ethernet card above will only work with round about 200kb/s and after a while the whole network connection will break down for more than a minute and than you will be back with your 200kb/s again.

So, this is really annoying and it’s nearly impossible to work with your machine. To solve this problem you have to use the official Realtek (r8168) driver instead of the r8169 driver, which is included in the Linux Kernel.

This tutorial will show you in a few steps, how you can build the official Realtek driver for the RTL8111/RTL8168 ethernet card for Ubuntu or Debian:

1. Get rootprivileges
Get root privileges, while typing “su” or (when you use Ubuntu) “sudo -s” in a terminal.

2. Get the requirements
To build and install the driver, we need the kernel headers and the build tools like gcc. To get them, just easily type in a terminal:

apt-get install build-essential

3. Get the driver
Now, go to the official download page from Realtek for the Linux/UNIX Driver for the RTL8111/RTL8168 ethernet card and download the latest driver version.
Link: Realtek Download Page

4. Untar the archive
The driver is compressed to an archive. So uncompress it with the following command:

tar xfvj r8168-8.025.00.tar.bz2

NOTE: Please do not forget to replace the “r8168-8.025.00.tar.bz2” with the driver version which you have downloaded!

5. Blacklist old driver
We have to blacklist the old driver (r8169) to prevent the system to load it. To do this, easily set a new entry in “/etc/modprobe.d/blacklist.conf” which is called:

blacklist r8169

or just enter in the terminal again

echo “blacklist r8169” >> /etc/modprobe.d/blacklist.conf

to do this in only one command.

6. Build and install the new driver
Now, the whole requirements to install the new driver are done. Let us now change in the driver directory, which we have uncompressed in a few steps before:

cd r8168-8.025.00

NOTE: Again, please do not forget, to change “r8168-8.025.00” to the version which you have downloaded.

The only think we have to do now is, to build the driver and install it. To build it, just type:

make clean modules

after a few secondes (depending on your CPU), the driver is build and you can install it with:

make install

7. Welcome r8168
One of our last steps is, to let the system know about the r8168 driver. With the command

depmod -a

you rebuild the kernel module dependencies and with an

insmod ./src/r8168.ko

you insert the new kernel module (the driver) into the kernel.

8. Make it available for boot
To always use the new module, you have to make a new initrd boot file. Just do

mkinitramfs -o /boot/initrd.img-`uname -r` `uname -r`

in a terminal. Here we make the initrd file with the help of the “uname -r” command, which allows us to get the version of the actually running kernel.
At least, you have to add in the “/etc/modules” file a new entry, which is called “r8168”, to get the driver automatically loaded after boot. As an alternative you can do the last step again with only one command:

echo “r8168” >> /etc/modules

That’s it! After a reboot you should have the best possible performance with the RTL8111/RTL8168 and additionally no other network problems should be available anymore (no break down).
After the reboot you can check if the right driver is loaded with this command:

lspci -v

with this command you should find your RTL8111/RTL8168 network card in a list and the additional command “Kernel driver in use: r8168”.

it doesn’ work. on realtek page i can find drivers for kernel 2.6, while ubuntu 11.10 has kernel 3.0. i tried the procedure with latest driver, and it doesn’t work: i don’t know if i did something wrong…

Thank you so much for sharing your pain. This really helped me too. I had no issue with RedHat 6.1 but when i went back with 5.5 my network never showed up and your step be step instructions solved my problem.

Well, i didn’t get it work. After restart two modules found – r8168 and r8169 which is still active. I think that old module needs to remove, something like – “sudo rmmod r8169”. And maybe – “sudo update-initramfs -u” is also needed? I’ve got Ubuntu 11.10 64bit.

The only issue I had was with the syntax of the commands you used. For instance, instead of:
mkinitramfs -o /boot/initrd.img-`uname -r` `uname -r`
I had to use:
mkinitramfs -o /boot/initrd.img-$(uname -r) $(uname -r)

…just thought I’d mention it, in case someone else has the same issue.

Hi – thank you very much for posting this. Your instructions work for me except the last step. When I run lspci -v after reboot, I get the following. Everything looks right except “Kernel driver in use: r8168” is missing

To get around the problem I suppose could put the depmod and insmod commands in a startup script, but that seems silly (and the depmod command takes a while to run). If you can think of anything else I should try, please let me know – thanks again!

Hm, let’s just say the gordian knot that is “build-essential” is not easily untangled offline. I tried installing Fedora Core 16, but it has the exact same problem with loading 8169. I could easily have solved the problem by chrooting into my Oneiric from Fedora, but, alas, ’twas not to be…

Last resort: now downloading a Precise Pangolin snapshot, fingers crossed.

Yeah, tried that and resulted in the same way. I’ve since given up and will wait for 12, hoping they’ve fixed it. Needed a working computer for now. Have tried all sorts from Ndiswrapper to varying methods upon your own that I’ve found with no luck.

I can’t remember the exact message but whenever I was doing the initramfs it warned me about compatibility, I think. My ethernet card is a slightly different model but automatically uses the r8168 driver in Windows with no problems. I tried the supposed original driver too but that didn’t work either.

Nope, before my change, I used two RTL8169s (one onboard, one as a PCIe card) and everything was working fine — this is, until the server began suffering kernel panics a few weeks ago. As I hadn’t changed a thing, I concluded that the hardware was breaking down.

Pre-Story:
I have installed Linux Mint 12 (3.0.0-12-generic) on my Extreamer Ultra but I’m having this problem like everyone else.
And my problem started when I installed Linux Mint, its said that it didn’t have any internet connection but the LEDs for the NIC are flashing and glowing (as it should be). But when the installation was completed I noticed that I didn’t have a internet connection.
But when I installed Ubuntu 11.10 it worked fine.

Problem 1:
I can’t even get pass step nr 2: “apt-get install build-essential”.
I get:
Err (website address)
Could not resolve ‘archive.ubuntu.com’
[This repeated around 10 times]
Fail to fetch (website address) Could not resolve ‘archive.ubuntu.com’
[This also repeated around 10 times]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?

But I suppose this is because it don’t have any connection to the internet.

Problem 2:
Step 5 – Blacklist
When I run the command i get and it doesn’t matter if I run it with “sudo” or not:
bash: /etc/modprobe.d/blacklist.conf: Permission denied

Are you sure that your network connection is running fine. For me it looks like, that your network connection has some problems, because there is no connection to the update servers possible.
Can you ping google.de? Can you ping 8.8.8.8?

Do you really have read my tutorial? I mentioned, that you should use “sudo su” to get complete root privileges for the whole proccess. If you do so, the “permission denied” error will not come back anymore.

Excellent! thanks for this my new desktop computer would not be usable without this!

Just out of curiosity I notic kernel updates wipe this out, and I have to compile and reinsert into the kernel each time, the blacklist, and everything else it there. Is there by chance a way to include it with the rest of thed rivers in the system so it can be injected at the time of kernel update?

No error in the terminal window. but I’m still getting “Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)” when I run “lspci”, and my connection is as buggy as ever.

Everything went fine, but it still didn’t solve my problem, that my WLAN is not on the list of avaible WLANs. Some others secured with passwords are listed, but my home WiFi is not. On Windows it works fine, but in Ubuntu 11 after changing driver to r8168 not. What is wrong?

Great Thanx for this !
I had the problem obn a dual boot system (ubuntu 11.10/win7) that after booting win7 the network under ubuntu was dead ! i had to plug off the !power cable! and reconnect it to get network under linux work again.
after switching the driver to the 8168 evrything works fine !
done under ubuntu 11.10 3.0.0-14-generic #23-Ubuntu SMP Mon Nov 21 20:28:43 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

I have a problem when i do the step where it says tar xfvj the packet. I downloaded it and everything and i put in the right name but when i do the step it says error no such directory and such of that

Most of these solutions are fine for systems with a single ethx. I have an onboard and a nic. The onboards needs the r8169 and the nic needs the 8168. what to do? This is a server BTW and the onboard is WAN, the nic LAN. netools sees it, and it passes a few packets, but no ip number and status shows link=no

Are you useing NetworkManager or the regular ifup method? Are you sure, that the complete system freezes? What’s happening when your pressing STRG+ALT+F2 / +F3 and so on? Did your system switches between the virtual consoles?

There is no keyboard response, so no way to switch to another console. Only single underscore is sometimes displayed in the upper left corner of the screen. So the system is most definitely frozen.
Is there any way to revert back to r8169 driver now, or at least temporarily disable the r8168 which seems to be the culprit? Simply blacklisting it did not do the trick.

[…] manufacturers that do care, the exceptions are notable – Intel GMA, Nvidia, Atheros, among others. Realtek is extremely popular ethernet chips on OEM boards, and while they do have drivers, they're not […]

Very thanks for this useful post.
I was surfing the web searching for rtl8111 datasheet, so I discovered the Issue you have reported.
Some comments report that this Issue exists also on Ubuntu 12.04 that is the platform I use for my LAN server… very thanks guys!!!!

[…] connect to the internet, and the r8169 was back in the kernel. I had found the instructions here – https://unixblogger.wordpress.com/201…ethernet-card/ – helpful, although that was written for the 11.10 version. Also even though the system was […]

I have r8168 Realltek card used with default r8169 driver. The problem is that I had pain to get a DHCP response (must wait a long time, invoking dhclient, which can simply nevers has an offer)
Tried to install the r8168, but things getting worse … never get an offer …

I think i’ve managed to go back (by rmmod r8168, blacklisting the r8168, and explicitely load the r8169, and redo a “depmod -a” and a “mkinitramfs ….”).
Not sure to have done everything well to go back …
For instance, is there, somewhere, some backups of initramfs ? Or does the mkinitramfs simply overwrite the former boot image ?

Finaly, is there a chance that this dhcp problem comes from the fact that ipv6 is disabled on my router ?
Tried to configure the networkmanager to use the same static IP (v4) or not, ignore (or not) ipv6 (but it still try to assign an ipv6 anyway …) …

Some more infos :
– ubuntu 11.04
– worked fine no so long time ago (when I installed ubuntu), and now, at each reboot, I have (real) pain to get connected
– close/reopen session, when previously connected, get reconnected directly …

Why am I getting these errors? I assume they are significant, because I tried to follow the later steps afterwards but they wouldn’t work for various reasons (including r8168.ko not existing).
Any idea what I’ve done wrong?

I did it again restarting at the “make clean modules” step and making sure that I used the “sudo -s” permissions this time. It sure looks like it worked just fine this time. I did get a “can’t read private key” error on the “make install” step but it doesn’t seem to matter. After I rebooted “lspci -v” reveals that I have both the r8168 and r8169 modules and the system’s using the r8168 driver. I’ll see if this corrects my wired network from randomly dropping. So far it’s been good so I’ll keep my fingers crossed.

Hey Unixblogger,
Thanks for your detailed explanation!
But still I didn’t manage to get wifi…
I blacklisted the 8169 (3times actually, as I saw in the gedit file)
I do see the 8168 driver in my extra programs (don’t know the english version)
It says the Realtek RTL 8168 Gigabit Eternet driver is in use.
But when typing in terminal: sudo lspci -v
the outcome is: kernel driver in use: 8169
kernel modules: 8168, 8169
Why won’t it work? I’m trying to make this work for days in a row…
Thanks in advance for your help!

I’m a novice user, but found your solution and managed to implement it. (I got what looked like a few error messages along the way, but it still worked). This was the end of about 8 hours of frustration – mostly thinking “surely this should work out of the box”!
Many thanks for your original, very clear solution.
John

I was having some connection stability issues with the r8169 driver in Mint 17 (kernel 3.13.0-24). After trying the latest driver from Realtek, problem solved. It’s worth noting that the entire process of compiling and installation has been automated with a script in the most recent release.

The latest incarnation of the NIC appears to be the RTL8111G (which appears in the Shuttle XH81V and DS47 machines). According to Realtek’s rather basic support/download site, lunux driver v8.039.00 supports the 8111G. Well, perhaps. The driver certainly gets the NICs going. But performance and reliability are another matter entirely. Forget Gigabit speeds – the 8111G can’t even deliver sustained throughput at 100mbps link speeds. It seems that the NIC frequently slows down or gives a flaky connection. Something’s very wrong. I plugged a generic £5 USB NIC into the XH81V, and its performance is far better than the onboard 8111G. That’s rather sad.

It looks like the same old Realtek story – pain, pain, pain wth every new product.

Hi
I have got ubuntu 14.04 with kernel version 3.16.0-57-generic. I have got RTL8111/8168/8411 PCI. The problem is I can not see any wifi network. I have followed all steps avobe and can see Kernel driver in use: r8168. But can’t see any wifi networks. Please help

Hi thanks for your tutorial and it really helps me solving most of my problem. I had a Linux workstation with realtek R8168 and was loading r8169 module. I followed your advice and it start working now. However when I was trying to SSH from my laptop to the Linux workstation I still found the connection very slow and may hangup for 1 or 2 minutes. Then I set up a SubVersion server on the Linux workstation and was trying to do a svn checkout of my laptop I found connect even failed. Can you please give more advice? Thanks in advance.

The easiest way would be to use a USB Ethernet card which is Linux compatible. There are a lot out in the wild which costs round about 5-10€ (or Dollars).

The way more complicate and unusual option is to download every single package which is needed by the build-essential package and all packages which depend on the dependencies for build-essential … you could say something like a never ending story.

So my adwise: Just get that cheap USB NIC for a temporary way of downloading and installing all needed packages.

To anyone still grappling with this issue. Note if you manage to get r8168 kernel module to load and you can see the interface in ifconfig -a but still cannot get to the router/internet, you need to ensure that the file /etc/network/interfaces has eth1 instead of eth0 in it.

If I had checked it earlier I would have saved an hour or so wondering what i did wrong with the module installation…

So there are just 3 possibilities right now:
1) You can wait until Realtek makes the driver Kernel 4.x ready.
2) You install and older 3.x Kernel and then go for the driver installations as described in this tutorial.
3) Someone posted in a earlier comment this driver: https://sourceforge.net/projects/network-card-driver/?source=navbar
You could download and compile this driver instead of the one from the Realtek homepage.

If you want to go with 3) and you have success doing compiling and installing, let me know so that I will be able to rewrite this tutorial.

So that reinstall drivers and boot with Linux Live OS but Ethernet not working…, I performed same on two same model PC’s and facing same network card issues !, So I don’t want to performed on another PCs.

My question is that, In built Ethernet is physically failed by Ubuntu on both machine ? How can first solve this issue in windows 7 ? and after Ubuntu ?

I’m sorry but it’s a little bit hard to understand your question(s). I try to answer it / them as good as possible:

First of all, you should check your BIOS settings. Eventually there are some settings which come across your ethernet. You could also restore your BIOS default settings for testing purposes here.
For Linux: Did you installed and used the official Realtek driver? How did you install the official driver? With apt-get or downloaded the driver by your own and installed it? What does lspci -v say?
For Windows: Well, try to reinstall the driver once more. Make sure you have the driver uninstalled before doing that (uninstall, reboot, reinstall, reboot, …).

Did you also tried another ethernet cable and another ethernet port within your switch / router? Your problem could also be hardware related …