How to Guide - Realtek RTL8111/8168B

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
rarsa
Level 1
Level 1
Posts: 39
Joined: Sun Jun 13, 2010 5:51 pm

How to Guide - Realtek RTL8111/8168B

Post by rarsa »

NOTE: I created this instructions under Linux Mint Debian Edition (LMDE) updated as of September 5, 2011. This instructions should work for other editions but I haven't tested them.

If you have a Realtek RTL8111/8168B, you may notice that the network connectivity is choppy.

This instructions are derived from the following post
http://www.foxhop.net/realtek-dropping- ... and-fedora
The Realtek r8168B network card does not work out of the box in Redhat, Centos, Fedora, or Ubuntu: instead of loading the r8168 driver, modprobe loads the r8169 driver, which is broken as can be seen with ifconfig which shows large amounts of dropped packets.
Here are the instructions to replace the driver in a nutshell
  • - Download the file from the oficial realtek site
    - Open a terminal
    - Change directories to where the downloaded file is
    - Extract it
    - Change directories to the extracted directory
    - Execute autorun.sh
    - If you are using kernel 3.x: Copy the r8168.ko file to the right place and load the module
Here are the detailed instructions:

- Download the file from the official site
http://www.realtek.com.tw/Downloads/dow ... wn=false#2

The rest of the steps depend on the filename and location of the downloaded file. Please adapt as required:

For example, if you download the file to your Downloads folder and the file is called r8168-8.025.00.tar.gz, the steps are the following

Code: Select all

cd ~/Downloads
tar vjxf r8168-8.025.00.tar.gz
cd r8168-8.025.00
sudo ./autorun.sh
If you are using kernel 2.x then you should be OK.

This script unloads and renames the r8169 driver so it does not cause any more trouble. There is no need to blacklist it but you can blacklist it if you want.

Code: Select all

echo "blacklist r8169" >> /etc/modprobe.d/blacklist.conf
If you are using kernel 3.0 you'll notice that the /src/Makefile has a bug that causes it to install the r8168.o file instead of the r8168.ko file

The solution is simple:

After the autorun.sh finishes, just do the following:

Code: Select all

sudo cp src/r8168.ko   /lib/modules/3.0.0-1-amd64/kernel/drivers/net/
sudo depmod
sudo modprobe r8168
And that's that.

In case you are curious about what the bug is:

Line 36 of the src/Make file is

Code: Select all

KEXT		:= $(shell echo $(KVER) | sed -ne 's/^2\.[567]\..*/k/p')o
Which sets the KEXT to "ko" for kernels 2.5, 2.6 and 2.7. It sets KEXT to "o" for anything else. This was OK at the time as kernel 3.0 is quite recent.

The fix is to also include kernel 3.0 in that instruction

Code: Select all

KEXT		:= $(shell echo $(KVER) | sed -ne 's/^2\.[567]\..*/k/p;s/^3\.0\..*/k/p')o

I hope this helps
Last edited by Oscar799 on Mon Dec 12, 2011 8:43 am, edited 1 time in total.
Reason: Title edited to make clear that it is a How To guide
-Snowrider-

Re: Realtek RTL8111/8168B [HOW-TO]

Post by -Snowrider- »

*NVM Got it working* Don't try editing the makefile just copy the file like it says.

Have you actually tested this with kernel 3. I followed you instructions and even edited the make file. I can't seem to get it to work.
wernher

Re: Realtek RTL8111/8168B [HOW-TO]

Post by wernher »

This helped me!
First I tried skipping the Linux 3.x part since they had changed the makefile, but it is still needed.
Thanks a lot!
gct

Re: Realtek RTL8111/8168B [HOW-TO]

Post by gct »

Hi! I created an account just to reply and tell you this post saved my life. I had the exact same problem and these steps fixed it perfectly. I went from being able to pull ~1MB/s off my NAS to > 20MB/sec with this fix!
User avatar
Oscar799
Level 20
Level 20
Posts: 10397
Joined: Tue Aug 11, 2009 9:21 am
Location: United Kingdom

Re: How to Guide - Realtek RTL8111/8168B

Post by Oscar799 »

Moved here by moderator
Image
scharkalvin

Re: How to Guide - Realtek RTL8111/8168B

Post by scharkalvin »

Why hasn't the r8168 driver been added to the kernel? Can it be added to LMDE?
I will need to try this fix for my new installation of LMDE Xfce on a GB GA970 motherboard which has the rt8111 chip.
In my case the ethernet does work but very slowly do to dropped packets. I was averaging 100kbs downloads during the initial system update and web pages were as slow to load as if on a old style 56kb modem (instead of 6mbs DSL). The interface works fine on Windows 7. I was about to try an old 3Comm PCI card from the junk box to fix the problem (bet there is no driver for it on Windows 7 64 bit!).
rezsbc

Re: How to Guide - Realtek RTL8111/8168B

Post by rezsbc »

Thank you for this!

I was at my wits end with my NIC only working at 100Mb speed for ages (since Kernel 2.6 or so, I'm using Ubuntu amd64 here).

Followed your instructions and they worked to a tee. The Realtek driver I used is "r8168-8.027.00" so slightly newer than the 8.025 version that was current at the time of the post. I didn't notice any error when running the autorun script, nor could I find the offending line in the Makefile however just to be sure (as I'm on kernel 3.0.14) I copied the .ko file and loaded it as you suggested. (Into /lib/modules/3.0.0-14-generic/kernel/drivers/net on ubuntu).

All working fine now! NIC autonegotiates to 1000Mb/sec, I was just transfering files to a windows laptop at 108MBytes/sec!!! Wow! Didn't stay at that speed for long, hard drives presumably can't keep up but this is a major improvement can't thank you enough!!!
jinkaz

Re: How to Guide - Realtek RTL8111/8168B

Post by jinkaz »

rarsa Thank You so much this worked like a charm! I tried everything from disabling ipv6 to making changes in the local.rc file however nothing worked till i tried this. the file I downloaded from the realtek site was r8168-8.027.00,unzipped and installed properly; no need to rename the ko file.
Thanks again rarsa!!!!!!!!!!!!!!!!!!!! :D
AlbertP
Level 16
Level 16
Posts: 6701
Joined: Sun Jan 30, 2011 12:38 pm
Location: Utrecht, The Netherlands

Re: How to Guide - Realtek RTL8111/8168B

Post by AlbertP »

Can anyone tell me if this is still needed on modern 3.1 or 3.2 kernels? I don 't own 8111/8168 hardware myself, my Realtek is (EDIT) 8101E.
Last edited by AlbertP on Thu Jun 28, 2012 4:14 am, edited 1 time in total.
Registered Linux User #528502
Image
Feel free to correct me if I'm trying to write in Spanish, French or German.
wizonesolutions

Re: How to Guide - Realtek RTL8111/8168B

Post by wizonesolutions »

This helped me somewhat, but I still encounter long page load times at times, and I'm not sure if I have a different issue. What tools can I use that would enable me to provide more information?

What basically happens is that the loading animation for a page spins for quite a while - sometimes 2-10x longer than it does on my Windows 7 machine. Both are using the same Internet connection and using wired Internet.

So r8168 definitely improved things, but there's still something (not sure what) happening that makes pages take a while to load. speedtest.net does show that I'm getting the speed I should be...technically. But even that site takes longer to load than it perhaps should. It seems the external elements on the pages themselves are taking a while. This happens in both Firefox and Chrome.

I'm not showing any dropped packets.

Is 1500 the right MTU for cable?

(P.S. Please redirect me to the right thread if I've misplaced this.)
Bruce0

Re: How to Guide - Realtek RTL8111/8168B

Post by Bruce0 »

Update:
The current version 8.029.00 does copy r8168.ko correctly on 3.0.0.17 Ubuntu 11.10 server, the make file seems (rather elaborately) fixed.

And Thanks... you fixed my problem, which was a reliable crash when running Mac TimeMachine backups to an afpd server backup disk, using LACP 802.3ad bonding. Would crash right away for me whenever a backup started (but not other copies oddly).

Anyway thank you.
yakupm

Re: How to Guide - Realtek RTL8111/8168B

Post by yakupm »

Thanks for the excellent howto. Somethings to note:
  • Have to do this whenever kernel upgraded.
    Don't have spaces in any directory/file name that is part of the path to the Realtek driver. I found this out when I upgraded to 8.029.00 - 2012/3/29.
    "If you are using kernel 3.0 you'll notice that the /src/Makefile has a bug that causes it to install the r8168.o file instead of the r8168.ko file" - this bug is fixed (I did not have to do this).
yakupm
AlbertP
Level 16
Level 16
Posts: 6701
Joined: Sun Jan 30, 2011 12:38 pm
Location: Utrecht, The Netherlands

Re: How to Guide - Realtek RTL8111/8168B

Post by AlbertP »

Linux 3.2 fixed most bugs, so you may not need this tutorial anymore in Mint 13 which will be released anywhere soon.
Registered Linux User #528502
Image
Feel free to correct me if I'm trying to write in Spanish, French or German.
nounours18200

Re: How to Guide - Realtek RTL8111/8168B

Post by nounours18200 »

Why hasn't the r8168 driver been added to the kernel?
This is also my question ! it is not an exotic chip, so it should have been included in the Kernel ! stupid...
Linux 3.2 fixed most bugs, so you may not need this tutorial anymore in Mint 13 which will be released anywhere soon.
I run Linux Mint-14 KDE, and it is impossible for me to connect my NAS directly to my PC (I am not an expert so maybe it is another pb) : so I have been obliged to connect it to my internet box, and it appears automaticcaly in Mint 14...
AlbertP
Level 16
Level 16
Posts: 6701
Joined: Sun Jan 30, 2011 12:38 pm
Location: Utrecht, The Netherlands

Re: How to Guide - Realtek RTL8111/8168B

Post by AlbertP »

Why hasn't the r8168 driver been added to the kernel?
The kernel has the r8169 driver which is supposed to support this device. r8168 was only used because the in-kernel driver did not work properly in the past (Mint 12 and before).
Registered Linux User #528502
Image
Feel free to correct me if I'm trying to write in Spanish, French or German.
nounours18200

Re: How to Guide - Realtek RTL8111/8168B

Post by nounours18200 »

The kernel has the r8169 driver which is supposed to support this device. r8168 was only used because the in-kernel driver did not work properly in the past (Mint 12 and before).
I am not an expert, but I run LM-14 , so a version later than LM-13, and the Realtek chipset is still not recognized...

I have followed the recommandation given above by rarsa, so I have downloaded and extract the Realtek 8111 driver from the Realtek website, but I have the following error with the ./ command:
elodie@elodie /media/elodie/SATA_06/SOURCES_L/Driver_Realtek_8111_Ethernet/r8168-8.035.00 $ sudo ./autorun.sh
[sudo] password for elodie:
sudo: ./autorun.sh: command not found
what is the pb with ./ command ???

Thanks
AlbertP
Level 16
Level 16
Posts: 6701
Joined: Sun Jan 30, 2011 12:38 pm
Location: Utrecht, The Netherlands

Re: How to Guide - Realtek RTL8111/8168B

Post by AlbertP »

Could you post the output these commands:

Code: Select all

inxi -N
dmesg | grep r8169
If it is an RTL8111/8168 yet not driven by r8169, it may be a new revision of the hardware. r8168 does not support those either since it is a much older driver (it does not seem to be still in development; Realtek is now actively maintaining r8169 instead).
Registered Linux User #528502
Image
Feel free to correct me if I'm trying to write in Spanish, French or German.
nounours18200

Re: How to Guide - Realtek RTL8111/8168B

Post by nounours18200 »

Here is the result:
elodie@elodie ~ $ inxi -N
Network: Card-1: Realtek RTL8111/8168B PCI Express Gigabit Ethernet controller driver: r8169
Card-2: Atheros AR5418 Wireless Network Adapter [AR5008E 802.11(a)bgn] (PCI-Express) driver: ath9k
elodie@elodie ~ $ dmesg | grep r8169
[ 1.677059] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[ 1.677150] r8169 0000:0b:00.0: >irq 83 for MSI/MSI-X
[ 1.677314] r8169 0000:0b:00.0: >eth0: RTL8168c/8111c at 0xf841a000, 00:24:8c:09:b7:a6, XID 1c4000c0 IRQ 83
[ 1.677316] r8169 0000:0b:00.0: >eth0: jumbo features [frames: 6128 bytes, tx checksumming: ko]
[ 22.721610] r8169 0000:0b:00.0: >eth0: link down
[ 22.721628] r8169 0000:0b:00.0: >eth0: link down
[ 25.013245] r8169 0000:0b:00.0: >eth0: link up
[ 30.835648] r8169 0000:0b:00.0: >eth0: link down
[ 35.246868] r8169 0000:0b:00.0: >eth0: link up
elodie@elodie ~ $
If it is an RTL8111/8168 yet not driven by r8169, it may be a new revision of the hardware
I would be surprised because my mother board is more than 3 years old, it is an ASUS P6T: so it is not a very new one...
The command you asked me seems to show that the Ethernet chipset is a r8169.

Thanks for your help
nounours18200

Re: How to Guide - Realtek RTL8111/8168B

Post by nounours18200 »

I finally succeeded in running the autorun.sh:
elodie@elodie /media/elodie/SATA_06/SOURCES_L/Driver_Realtek_8111_Ethernet/r8168-8.035.00 $ sudo bash autorun.sh
[sudo] password for elodie:

Check old driver and unload it.
rmmod r8169
Build the module and install
Backup r8169.ko
rename r8169.ko to r8169.bak
DEPMOD 3.5.0-17-generic
load module r8168
Updating initramfs. Please wait.
update-initramfs: Generating /boot/initrd.img-3.5.0-17-generic
Warning: No support for locale: fr_FR.utf8
Completed.
But the next command suggested at the very beginning of this post does not run:
elodie@elodie /media/elodie/SATA_06/SOURCES_L/Driver_Realtek_8111_Ethernet/r8168-8.035.00 $ sudo cp src/r8168.ko /lib/modules/3.0.0-1-amd64/kernel/drivers/net/
cp: impossible de créer le fichier standard «/lib/modules/3.0.0-1-amd64/kernel/drivers/net/»: Aucun fichier ou dossier de ce type
the system says that there is no file or folder of this type...

Any advices ?
AlbertP
Level 16
Level 16
Posts: 6701
Joined: Sun Jan 30, 2011 12:38 pm
Location: Utrecht, The Netherlands

Re: How to Guide - Realtek RTL8111/8168B

Post by AlbertP »

Ok, it's indeed not a new device revision; but it appears r8169 is already working at you. Note that this is your wired ethernet. Your wireless has nothing to do with r8169 vs r8168.

Also you can just run "sudo make install", I think, instead of that command. (With that cp command you need to replace 3.0.0-1 with your kernel version, which you can see with uname -r in terminal. But you do not need to do that if you can use sudo make install)
Registered Linux User #528502
Image
Feel free to correct me if I'm trying to write in Spanish, French or German.
Post Reply

Return to “Tutorials”