Script to Fix R8168 and R8111 in Debian/Ubuntu GNU/Linux

May 5, 2008

( Also available in Spanish. )

The new Realtek r8168/r8111 network cards do not work out of the box in recent distributions of GNU/Linux. modprobe loads the r8169 module, which has not yet been updated to work with these cards. A work around is to use the r8168 driver provided by Realtek.

Download and Run the Script

I have written a shell script to automate the module switch. I also have precompiled versions of the module if you’d like to manually insert one of those, although I do not update these regularly. Both methods are working, and all relevant files can be downloaded at nosemaj.org/dl/r8168_scripts.tar.bz2. To use my script, uncompress the tarball, enter the directory, and run the switchmods script:

tar xjf r8168_scripts.tar.bz2
cd r8168_scripts
sudo ./switchmods;

It may be easier to just manually switch in my version of the module (r8168.ko), but this will not succeed if you are running a different kernel/architecture. Please let me know if you have any questions or problems.

Types of Systems Effected

This problem affected (at least) my setup, which was:

lspci  | grep Ethernet
07:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02)
uname -mro
2.6.24-21-generic x86_64 GNU/Linux

This work around has been confirmed to work for a wide variety of systems running various types of Debian and Ubuntu family operating systems. There is very little specific to Ubuntu Hardy, which was where I originally noticed the problem.

Key Steps in getting R8168 module to work at boot

I have had success by compiling a module from source. Below is a description of what I did to get a working r8168 module for my system. (Again, my script does all of this for you, and with more safety checks.)

Get root privileges:

sudo bash

Trash the non-functioning module:

rmmod r8169

Get the 8168 driver source. UPDATE: Realtek has removed direct access to the source tarballs. You will need to manually visit the website and download the Linux tarball for the R8168/R8111 family NICs. Then:

tar xjf r8168-8.011.00.tar.bz2
cd ./r8168-8.011.00

Now compile the code. This may fail if you don’t have kernel headers and other standard features of a build environment:

make clean
make modules
make install

Make sure modprobe knows not to use r8169, and that depmod doesn’t find the r8169 module:

echo -e "\nblacklist r8169\n" >> /etc/modprobe.d/blacklist
mv /lib/modules/$(uname -r)/kernel/drivers/net/r8169.ko{,.bak}

Let the OS know about the new module:

depmod
insmod ./src/r8168.ko

Put your work in the initrd, too:

mv /boot/initrd.img-$(uname -r){,.bak}
mkinitramfs -o /boot/initrd.img-$(uname -r) $(uname -r)

Reboot!

shutdown -r now

Resources for the Older Realtek Code

Before version 8 was released, the Realtek code needed a patch. If for some inconceivable reason you want to use the obsoleted version instead, you can download the old tarball which handles the patching.

See Also

238 Responses to “Script to Fix R8168 and R8111 in Debian/Ubuntu GNU/Linux”

  1. Kim Emax says:

    Hi There. I´ve been struggling with this myself for more than a week now, gonna try your solution tonight but I´m just wondering, have you tried and failed with the v.6 of the driver, since you use v.5?

    Take care
    Kim Emax

  2. Kim Emax says:

    Ahh.. sorry, the link target _is_ for v.6, the name just says v.5 :-)

    /Kim

  3. Jameson says:

    Kim,

    I did try v6, and it didn’t work immediately. I tried to modify the patch for v6 but that didn’t work after a few minutes of effort, and having read the changelog between the drivers, I decided no one is missing out by using the “old” version, other than in the sense that it is philosophically pleasing to use the latest stuff. Well, I didn’t read it too close – but it was short. v7 might be a different story.

    The see also links were indeed supposed to be to v5 – thanks for letting me know, I have updated them.

  4. jf says:

    small typo in your script:

    mv 8169.ko r8169.ko.bak

    should be

    mv r8169.ko r8169.ko.bak

  5. Jameson says:

    Justin –

    Glad you caught that! The script and the instructions on this page have been updated accordingly.

  6. Kris says:

    Hi,
    i am pretty new to linux and ubuntu and i am having the same problem on both my desktops(intel d945GC) which has RealTek RTL8101E/8111B Ethernet LAN Controller. after spending a day on the web searching for a soln i think it might be simialr to the issue you found and resolved. Since i am new to linux can u please list the exact steps to follow in ubuntu to install your script and get my lan connection working. thanks in advace for your help.

  7. Jameson says:

    Hi Kris,

    Can you show me your output from lspci and lsmod? I believe R8101E is a 100Mbps chip, and 8111B is a gigabit chip. I am fairly sure that the two controllers use different drivers.

    8111x (as in 8111, 8111B, whatever) should work with my script. To use it, all you need to do is:

    1. Download this file: r8168_scripts.tar.bz2 – er, or get it onto your computer somehow, since you don’t have a LAN connection atm.
    2. Open a command line as root (or using sudo), go to the directory to which you saved the file, and type: tar xjf r8168_scripts.tar.bz2
    3. Next, enter the new directory, by: cd r8168_scripts
    4. And run my script by typing: ./switchmods

    If it turns out you don’t have an 8111x, my script could be adapted to work with 8101E if the problem is caused by the same things. You would just need to replace references to 8168 and the 8168 driver source with 8101E and the source that Realtek provides for the 8101E. Depending on how bored I am this weekend I could beef up my script to handle both.

    If you have any more trouble, please post the output of ./switchmods here, and I’ll try to help you along.

    Jameson

  8. Jameson says:

    Update:
    The patched version of the v6 driver source produces a working kernel module. It is now included in the tarball. Also, there has been a kernel update to 2.6.24-17-generic, and I have included a compiled v6 module for this kernel, as well.

  9. Marco says:

    Great job friend. Saved my skin here, thank you. :)

  10. jody says:

    where can i get the r8168-8.006.00.hardy.diff.txt so version 6, the stuff was working on 2.6.24-16 with the realtek source r8168-8.006.00 but now it does not work anymore how to proceed?

  11. jody says:

    ok i guess i have to do something with the precompilled thing, but what exactlc? sorry kind of new to linux :) thx

  12. jody says:

    ok problem solved, it was just a permission problem :) thx again :)

  13. Jameson says:

    The patch still works on 17-generic. It mainly deals with changes to the net_dev structure that took place between 2.6.23 and 2.6.24. 16-generic, for reference, was 2.6.24.3. So, you should be able to compile the r8168.ko module just fine against the 17-generic headers. Make sure you have the source and headers for the 17-generic release before attempting to compile the module:
    sudo apt-get build-dep linux-image-2.6.24-17-generic;
    sudo apt-get source linux-image-2.6.24-17-generic

    If you’d like to avoid that and use my precompiled module, follow the directions on this page, except skip everything inside of the lines rmmod r8169 and depmod -a. Instead, of those interior lines, copy the precompiled module into the appropriate /lib/modules dir, naming it “r8168.ko”:

    cp r8168_scripts/precompiled/r8168.ko.v6.17-generic
        /lib/modules/2.6.24-17-generic/kernel/drivers/net/r8168.ko

    Hope this helps, let me know if you have any more trouble.

  14. jody says:

    sorry to bother again, i downloaded the tarball, did:
    rmmod r8169
    depmod -a
    cp r8168_scripts/precompiled/r8168.ko.v6.17-generic
    /lib/modules/2.6.24-17-generic/kernel/drivers/net/r8168.ko
    then did
    insmod r8168.ko
    but get an error:
    insmod: error inserting ‘r8168.ko': -1 Invalid module format
    what am I doing wrong? thx for the help again :)

  15. gus says:

    Hi jody,
    what do you mean with permission problem?. I was trying different chmod but get always the same error:
    insmod: error inserting ‘r8168.ko': -1 Invalid module format

  16. Jameson says:

    Gus,

    Can you provide the output of the following commands?

    uname -rmo and
    modinfo ./r8168.ko where the above is for the module you’re trying to insert? The modules I have built are suitable only for the x86_64 kernels.

    You might also have luck with the switchmods script which has just recently been souped up a bit. :-P

  17. jf says:

    btw , this also works on kernel 2.6.24-16-generic.

    if you upgrade to 2.6.24-17 you’ll need to re-execute the script again.

  18. jf says:

    found another bug…

    when you start doing the “make clean”…etc you need to cd from r8168-8.005.00/src to
    r8168-8.005.00

    a “cd ..” before “make clean”.

    and then a “cd src” right before the “insmod r8169.ko”

  19. Jameson says:

    Yes, absolutely! Thanks for noticing. I had those correct in the script, but not up on the page here. Your attentiveness is appreciated. :-)

    Jameson

  20. jf says:

    sorry if it appears that i’m nit picking.. there’s another small bug..

    shudown -r now

    should be

    shutdown -r now

  21. gus says:

    Hi Jameson,
    Here are the outputs.
    uname -rmo
    2.6.24-17-generic x86_64 GNU/Linux
    and

    modinfo ./r8168.ko
    8.006.00-NAPI
    license: GPL
    description: RealTek RTL-8168 Gigabit Ethernet driver
    author: Realtek and the Linux r8168 crew
    srcversion: D9A83968C84AF7A448302F9
    alias: pci:v000010ECd00008168sv*sd*bc*sc*i*
    depends:
    vermagic: 2.6.24-17-generic SMP mod_unload
    parm: speed:force phy operation. Deprecated by ethtool (8). (array of int)
    parm: duplex:force phy operation. Deprecated by ethtool (8). (array of int)
    parm: autoneg:force phy operation. Deprecated by ethtool (8). (array of int)
    parm: rx_copybreak:Copy breakpoint for copy-only-tiny-frames (int)
    parm: use_dac:Enable PCI DAC. Unsafe on 32 bit PCI slot. (int)
    parm: debug:Debug verbosity level (0=none, …, 16=all) (int)

    In my last post I was trying to install the v5.16-generic to see if it work because the precompiled v6.17-generic didn’t work for me. With the last corrections in your script I have almost managed to compile. Almost because by the insmod says “Failed to insert module.”. Actually the new module was copied to the to the right place (/lib/modules dir) but somehow the insmod fails. The rest I could do manually and I think now the module is correctly installed and the r8169 is eliminated. The problem is that the card is still not working. It behaves the same as before with the wrong r8169, no communication with the router. It gets a weird ip 169. 254.2.107 and 255.255.0.0 netmask.
    My nic is not a card but an on-board one.

    lspci | grep Ethernet
    02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 01)

    Perhaps is this the problem but there is no newer drivers for linux than those you patched.
    Thank you anyway for your great job with the scripts.

    gus

  22. Jameson says:

    Gus,

    I’m not sure what the problem could be, yet. I don’t think it’s that our chips differ in revision number, though. ;-) You might try various modprobe commands instead of insmod to try and get a scrap more feedback as to why it’s not gluing with the running kernel code.

    I don’t understand how you’re getting even an IP if you don’t have a kernel module loaded for the NIC. I could not get an IP with 8169. You can check if either is loaded with:

    lsmod | grep -E "8168|8169"

    Perhaps you could also supply the output of these commands:

    grep -E "8168|8169" /lib/modules/2.6.24-17-generic/*
    and modprobe -c | grep -E "8168|8169"
    I have the following output for the above, respectively:

    /lib/modules/2.6.24-17-generic/modules.alias: 
       alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168
    /lib/modules/2.6.24-17-generic/modules.dep: 
       /lib/modules/2.6.24-17-generic/kernel/drivers/net/r8168.ko:
    /lib/modules/2.6.24-17-generic/modules.pcimap: 
       r8168 0x000010ec 0x00008168 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0
    

    and

    blacklist r8169
    alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168
    
  23. gus says:

    The weird IP I get seems to be the default address that will be assigned using dhcp when no connection to the router. Using fix IP it shows as it uses it but still no traffic

    Actualy I do have the r8168 loaded and the r8169 killed as you see in the outputs. But still not working.

    Thanks

    Gus

  24. gus says:

    hi jameson,
    Here they are. It comes out exactly the same as you get.
    grep -E “8168|8169″ /lib/modules/2.6.24-17-generic/*

    /lib/modules/2.6.24-17-generic/modules.alias:alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168
    /lib/modules/2.6.24-17-generic/modules.dep:/lib/modules/2.6.24-17-generic/kernel/drivers/net/r8168.ko:
    /lib/modules/2.6.24-17-generic/modules.pcimap:r8168 0x000010ec 0x00008168 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0

    and

    modprobe -c | grep -E “8168|8169″

    blacklist r8169
    alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168

    It seems to be everything right but it does not work. I was googling around and found something about irq collision between the NIC and the IDE controler but I do not know how to deal with this.

    Thank you very much anyway,

    Gus

  25. Jameson says:

    This fix still works on the new 18-generic stuff. It seems a bit slower, though. I had to use the script myself for the new kernel and so updated it quite a bit. (see changelog.)

  26. gus says:

    jameson,

    Thank you anyway. Where can I find the changelog of the 18-generic kernel development?.

    Gus

  27. Roti says:

    Thanx a lot, it saved my time!
    Roti

  28. graeme says:

    https://bugs.launchpad.net/ubuntu/+source/linux/+bug/141343

    Someone just posted:

    “I just installed 2.6.24-18, and the r8169 driver works!”

    Can you guys confirm?

  29. Jameson says:

    r8169 was not working for me in 18-generic, either. I am curious as to how it was for that person.

  30. graeme says:

    I hope they fix this soon — we need to ship off our server to colo and don’t want to keep it at the current kernel and wonder if the next upgrade might kill the network again. :(

  31. Dirk says:

    Thank you for this solution !! It is working nice on my Asus A6T laptop, I hope the Ubuntu guys solve this problem fast !! Or maybe it’s the Kernel guys who should solve this.

  32. Marcos says:

    I have a toshiba satellite L300 and i can only start ubuntu hardy if i disavle the LAN r8101E at the bios setup and i cant get it to work even if i try to make it run after i install it always gives an error at /sbin/modprobe… How can i adapt your script for my LAN device???

  33. Jameson says:

    Marcos,

    You just need to replace references to the r8168 driver source with references to the correct source for your card (which you should download so the script can use it.) It might not be called r8168, so change references to that to the correct name also. Remove the stuff about the patch.

    Jameson

  34. jf says:

    i can confirm that this card does not work with the new .18 release of the generic kernel on Hardy

    had to rerun the Jameson’s script again.

  35. Jameson says:

    Yikes. Good call.

  36. Jarle Thorsen says:

    Found a small bug in switchmods:
    echo “nblacklist r8169n” >> /etc/modprobe.d/blacklist
    needs to use the -e argument to have echo enable interpretation of backslash escapes. So it should read:
    echo -e “nblacklist r8169n” >> /etc/modprobe.d/blacklist

  37. Brendan says:

    Your script did the trick for me. Works a treat.

    Thanks dude.

  38. Karsten says:

    Thank you so much for this. My new HP-PC always froze completely when loading the r8169 driver, so i couldn’t even boot ubuntu. I am using your precompiled module (r8168.ko.v6.18-generic) and it works like a charm. I hope you keep providing new modules as kernel updates are released, or i will be locked out again.

  39. Jameson says:

    You got it Karsten – will keep puttin’ em out so long as it’s not fixed upstream or at ubuntu. :-)

  40. rew2 says:

    hey there after typing ./switchmods I get the following lines in return

    Attempting to remove running r8168 and r8169 modules if loaded…
    Attempting to move /lib/modules/2.6.24-16-generic/kernel/drivers/net/r8169.ko to /lib/modules/2.6.24-16-generic/kernel/drivers/net/r8169.ko.bak.
    Blacklisting r8169 in /etc/modprobe.d/blacklist…
    Creating a tmp dir in which to buil the module…
    Attempting to apply the patch…./switchmods: line 79: patch: command not found
    OK
    Checking for gcc and linux-headers-2.6.24-16-generic… OK
    Attempting to build the module…/tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_init_board’:
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:2300: error: implicit declaration of function ‘SET_MODULE_OWNER’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_init_one’:
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:2600: error: ‘struct net_device’ has no member named ‘poll’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:2601: error: ‘struct net_device’ has no member named ‘weight’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_rx_interrupt’:
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4029: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4029: warning: type defaults to ‘int’ in declaration of ‘_y’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4029: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4029: warning: comparison of distinct pointer types lacks a cast
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_interrupt’:
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4225: error: too few arguments to function ‘netif_rx_schedule_prep’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4226: error: too few arguments to function ‘__netif_rx_schedule’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_poll’:
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4274: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4274: warning: type defaults to ‘int’ in declaration of ‘_y’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4274: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4282: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.c:4285: error: too few arguments to function ‘netif_rx_complete’
    make[3]: *** [/tmp/tmp.LXOjBj6310/r8168-8.006.00/src/r8168_n.o] Error 1
    make[2]: *** [_module_/tmp/tmp.LXOjBj6310/r8168-8.006.00/src] Error 2
    make[1]: *** [modules] Error 2
    make: *** [modules] Error 2
    install: cannot stat `r8168.ko': No such file or directory
    make[1]: *** [install] Error 1
    make: *** [install] Error 2
    Could not build module.

    can anyone tell me what to do?
    thanks in advance

  41. Jameson says:

    If you have internet access with another interface on the computer, then:

    sudo apt-get -y install patch

    Otherwise, install the patch package with the package manager using the Ubuntu CD as the repo.

  42. VastOne says:

    Hi Jameson,

    Appreciate all your diligence and expertise and help to all levels of users!

    modinfo r8169 shows
    /lib/modules/2.6.24-19-generic/kernel/drivers/net/r8169.ko

    I have had intermittent issues with this eth0 from the initial install of hardy having to add the RO PCI=NOPCI just to get Hardy to first install and then load

    I have also been through the Wake On Lan and the Vista crap and fixed that….

    Safe Boot shows I have a ETH0: RTL8168c/8111c…

    Now to the question:

    Has this script been updated for the 2.6.24-19-generic/kernel or does anyone know if this has been fixed upstream?

    I am hesitant to change the setup I have if I do not need to???

    Thank you

    V1

  43. Jameson says:

    Hey, yes – I still needed to run my script for 19-generic. Doing so should still work fine, and I encourage you to give it a try.

    The only change to 8169 or net device code that took place between 18 and 19 was to

    “fix oops in r8169_get_mac_version”

    The r8168 code still needs to be updated to reflect that the napi_struct stuff is no longer in the net_device structure – but that is Realtek’s prerogative. (See here: http://lwn.net/Articles/244640/)

  44. VastOne says:

    Jameson,

    Another reboot and I have my IP back via ETH0:

    I do not understand why the script did not run?

    I see that I am not the only one who had this same issue….

    And again, I am fully functional and curious as to why I am connecting fine while others are dead…?

    V1

  45. VastOne says:

    Brilliant… Saw it but missed it all at once….

    Can blame a rough morning but I wont!

    Thanks!

    V1

  46. VastOne says:

    Jameson,

    I am now online via the wireless side of the RTL8168c in my Ubuntu setup…Can only get an IP via wireless now…This is after I attempted the script and received the following:

    Attempting to remove running r8168 and r8169 modules if loaded…
    Attempting to move /lib/modules/2.6.24-19-generic/kernel/drivers/net/r8169.ko to /lib/modules/2.6.24-19-generic/kernel/drivers/net/r8169.ko.bak.
    Blacklisting r8169 in /etc/modprobe.d/blacklist…
    Creating a tmp dir in which to buil the module…
    Attempting to apply the patch…./switchmods: line 79: patch: command not found
    OK
    Checking for gcc and linux-headers-2.6.24-19-generic… OK
    Attempting to build the module…/tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_init_board’:
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:2300: error: implicit declaration of function ‘SET_MODULE_OWNER’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_init_one’:
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:2600: error: ‘struct net_device’ has no member named ‘poll’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:2601: error: ‘struct net_device’ has no member named ‘weight’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_rx_interrupt’:
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4029: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4029: warning: type defaults to ‘int’ in declaration of ‘_y’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4029: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4029: warning: comparison of distinct pointer types lacks a cast
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_interrupt’:
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4225: error: too few arguments to function ‘netif_rx_schedule_prep’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4226: error: too few arguments to function ‘__netif_rx_schedule’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c: In function ‘rtl8168_poll’:
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4274: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4274: warning: type defaults to ‘int’ in declaration of ‘_y’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4274: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4282: error: ‘struct net_device’ has no member named ‘quota’
    /tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.c:4285: error: too few arguments to function ‘netif_rx_complete’
    make[3]: *** [/tmp/tmp.AMejQf7275/r8168-8.006.00/src/r8168_n.o] Error 1
    make[2]: *** [_module_/tmp/tmp.AMejQf7275/r8168-8.006.00/src] Error 2
    make[1]: *** [modules] Error 2
    make: *** [modules] Error 2
    install: cannot stat `r8168.ko': No such file or directory
    make[1]: *** [install] Error 1
    make: *** [install] Error 2
    Could not build module.

    Any ideas will be very appreciated…

    Thanks

    V1

  47. Jameson says:

    V1,

    The following line was in your output:

    Attempting to apply the patch…./switchmods: line 79: patch: command not found

    As covered directly above, this means you need to install the GNU patch utility. ;-) While connected to your wireless internet, you can install patch by issuing:
    sudo apt-get -y install patch

    I have now added a check for this in the the switchmods script so that the problem will be caught earlier on and the output will be more visible.

  48. Luis says:

    Hi this script worked fine before on kernel 2.6.24-19 but now after having reinstalled ubuntu the script wont run and I get the error 2 message.

  49. Jameson says:

    Luis,

    Please post the error message here, along with the output of lsmod | grep r81 and lspci | grep -i eth

    Jameson

  50. David Higgins says:

    I know next to nothing about Linux and can’t get this to work :( The original script.tar.bz2 doesn’t contain a 19-generic and trying any of the others just results in a ‘wrong format’ error! I’ve just got a standard Ubuntu 8.04.1 install and no connection to anything (Network or Internet)

  51. Jameson says:

    Hi David –

    The script doesn’t rely on the precompiled modules, but I’ve thrown in my 19-generic module that I’ve been using now, in case it helps. If you reply back with the error message you get while running the script I may be able to help.

    Jameson

  52. David Higgins says:

    Oooooo….. I think it worked. I just ran the new script folder and everything reported OK (mind you it took a bit of trial and error to install the GNU patch since 1. My CDROM couldn’t be seen by the package editor and 2. GNU Patch is just ‘patch’ in the package editor!)

    I’ll have to wait till I get home and connect to my LAN to see if this worked.

    Many thanks for your efforts Jameson. It’s not often you find someone with such patience and a willingness to help the LINUX illiterate (like myself)

    Cheers

    David

  53. David Higgins says:

    Hi Jameson,

    I use your precompiled generic 19 then logged in as root I do:

    depmod
    insmod r8168.ko

    and the system returns :

    insmod: error inserting ‘r8168.ko': -1 Invalid module format

    Cheers

    David

  54. Fernando F. Teixeira says:

    Work very well, in Ubuntu Ultimate Edition 1.8 x86_64.
    I had this problem along time, but I didn’t know how to solve.
    Congratulations and thanks!!!

  55. Pablo Bardelli says:

    Hi Jameson,
    the script worked very well and now I’ve wired internet (and local network!!!)
    I am a newbie to GNU/Linux and my Ubuntu Hardy was performing excellent except for this bug that I tried to solve for weeks. Now everything is great!!

    Thank you very much for your effort!

    Cheers
    Pablo

  56. Andreas says:

    Hi!
    Fantastic script!!! :-)

    Can you please provide a script for RTL8101E, as written above?
    R8168 doesn’t work for me and I don’t know how to change the files within the script :-(

    BTW: Please add a check if kernel-headers are installed. I didn’t have and this crashed my network :-S

    Thank you!!!

  57. Andreas says:

    Addition: The 8168 crash my complete networking… eth0 is not shown and can’t be activated… how can i restore the old configuration?

  58. Jameson says:

    Andreas, I certainly believe that – this script is not for the R8101E. The steps should be almost the same, but you’ll want to use this driver source, and not call anything an “r8168.” As I do not have that chip, I have little interest in producing a script for it – and more to the point, I would not be able to test it out anyway.

  59. Andreas says:

    Hi Jameson,
    ok, I can understand your decision.

    I hope I solved it now as followed:
    – Download patched driver from http://www.silentpcreview.com/forums/viewtopic.php?p=420867, copy it via USB-Stick to my R8101-Machine,
    – make clean modules
    – make install
    – depmod -a
    – /etc/modprobe.d/blacklist: add “blacklist r8186″ and “blacklist r8169″
    – update-initramfs -u

  60. Markus says:

    Hi,
    i just tried to compile the latest version from Realtek (8.008.00) with kernel 2.6.24-19: The patch isn’t needed anymore. It compiles just smoothly with only some minor warnings.

    Markus

  61. Tomek says:

    Fantastic! :)
    I only had to install ‘patch’ package on my Ubuntu in order to run switchmods script! Excellent job Mate!

    Best,
    Tomek

  62. Dirk says:

    Hello,

    i tried to compile the latest (8.008.00) driver but i got an error message (sudo make modules) that there is no rule for makefile.
    Is it possible to integrate the new driver into the script (which works really perfect)?

    Dirk

  63. Jameson says:

    Dirk –

    I haven’t had a chance to have a look at the new source yet (which according to Markus above has been fixed.) I will be sure to have a look in the next few days and adapt my script as necessary. Keep a look out!

    Jameson

  64. Dirk says:

    Hello,

    is it possible ti integrate the new Realtek driver (8.008.00) into this script? Because I tried to compile the new driver and i got an error message (during sudo make clean modules) that there is no rule for /scr(Makefile).

    Dirk

  65. Jameson says:

    Dirk –

    Hold your horses! I was working on the script changes last night; those were quick. The new tarball and changes to this page should be up later tonight, I think.

    Jameson

  66. Jameson says:

    Okay, the v8 stuff is up. This page no longer deals with the old codebase except for the new note at the end. Let me know if you have trouble.

  67. Fert says:

    Im so lost… all i can tell you is that i just now got into linux and i have a usb card that lets me connect but ubuntu now wont even detect a hardwire connection… i need help i really dont like wireless

    if you can that would be great

    July 17th, 2008 at 9:42 pm

  68. Jameson says:

    Fert, I’m not sure how you got here. if you do an lsmod | grep r8 and see r8169 listed, and lspci reports that you have the appropriate NIC, then use this script, otherwise checkout the forums.

  69. Dirk says:

    Hi Jameson,

    sorry for the “double post”. I could not see my first one, so i thought something was wrong. Sorry for that.

    Thank you for updating the script. It worked fine.

  70. muhdazmil says:

    thank your 4 the solution

  71. Dave says:

    The “switchmods” script worked perfectly. For the benefit of googlers, my machine is an Asus M50vm.

  72. Don says:

    The script worked perfectly on a Dell Studio Hybrid.

  73. Andrew says:

    Awesome work. Just built a development box on a Gigabyte GA-ep45-ds3l motherboard and was really confounded by all the corrupted apt fetches. I thought my drives or memory or something was fubar, but then I noticed the crazy random {md5,sha1}sums when I tried manually downloading packages. This package fixed it nicely. FWIW, it also looks like Intrepid’s kernel works fine as well. Thanks!

  74. Joe says:

    works fine for my Dell Vostro 1310
    many thanks for this easy-to-use skript

  75. meatric says:

    many thanks, work succesfully!

  76. Refrigerator says:

    Patch didn’t work for me. I applied it and it appears in hardware-drivers as “active” and “in use”.

    Also enabled the Wake-on-Lan option in BIOS but it still doesn’t connect :(

  77. Refrigerator says:

    i have a Vostro 1310 btw.

  78. Jameson says:

    Refrigerator, I am unsure what you mean by “hardware-drivers.” Please post the output to the various commands I’ve asked other people to post, as above.

  79. Refrigerator says:

    Well there is a “hardware-driver”-window in the german version which shows the not-proprietary-drivers. First it was only showing a “wl” for the wlan. But after applying your script the “RealTek RTL-8168 Gigabit Ethernet driver” was added.

    But nevermind, i got it running now. I had to navigate through the “pppoeconf” command and now it works. thanks :D

  80. Jameson says:

    Okay, cool! Glad to hear your issue was resolved.

  81. Erez K says:

    Worked smoothly on my HP m9340f with ubuntu.
    8.0.41 desktop for 64bit processors.
    Wired works, now wireless in my next task…
    Installing the patch was a breeze:)
    Many thanks!
    Erez

  82. DesG says:

    I have this r8168 Realtek on my motherboard also, for google, the model number is Asus P5GC.

    Thanks for the script, I don’t suppose you know anything about DKMS for automatically recompiling drivers during kernel upgrades, see section 5 of http://wiki.centos.org/AdditionalResources/HardwareList/RealTekRTL8111b

    Cheers, Des.

  83. Luke says:

    Hi there,

    I have been having problems with the Realtek 8111C for a while now. Is there any chance that this script would work on OpenSUSE 11. I have 4 office computers with this NIC. Any help would be greatly appreciated.

    Kind regards,

    Luke

  84. CreativeThings says:

    Hi,

    thanx!
    Your script works like a charm!

    regards,
    Niels

  85. Jameson says:

    Luke,

    I do not believe that mkinitramfs exists in the SUSE world, so you’ll need to find a way to make the updates to your initrd. Otherwise, I don’t believe there should be anything that would cause a problem.

    Jameson

  86. AutoStatic says:

    Hello, just leaving a note to say that I managed to fix my network problems with the help of your info. I have exact the same nic and it just refused to go up every now and then. Hopefully this is fixed now. BTW, Fedora 9 has exactly the same whims.

    Jeremy

  87. Luke says:

    Dear Jameson,

    Thank you very much for your help – I’ll keep looking into it.

    Thanks again for all your help.

    Regards,

    Luke

  88. Jabes says:

    Thank you so much! I’ve been trying to get my R8168 to work in Hardy for a couple of hours, but with no luck. This fixed it in 10 seconds flat.

  89. Alex says:

    Thank you very much for the step-by-step instructions. They worked absolutely smoothly!

    Also, as an info for everyone, I hear that the problem should be fixed in 8.10 as well as 8.04.2 and the card should work out of the box then.

  90. Pavos says:

    Thanks a lot,
    I have a vostro 1310 laptop and I couldnt connect it.
    Now with your script I am writing this message to you.
    Thank you very much!!!!!!

  91. Raghu says:

    Hi,
    Although networking worked from the the live CD(8.04.1LTS) on my new Vostro 1710, it did not work, after installing Ubuntu.
    Running your script fixed the problem.
    Thanks a lot.
    Raghu

  92. kasjak2000 says:

    Hi Jameson,

    I have here a vostro 1310 with this lan-interface and debian etch 4.0r4 (the latest stable) 2.6.18-6-amd64.
    I followed you steps like in post 7. After run ./switchmods I get:

    x64etch:/home/egunia/drivers# ls
    r8168_scripts r8168_scripts.tar.bz2
    x64etch:/home/egunia/drivers# cd r8168_scripts
    x64etch:/home/egunia/drivers/r8168_scripts# ./switchmods
    Attempting to remove running r8168 and r8169 modules if loaded…
    ACPI: ACPI: PCI interrupt for device 0000:07:00.0 disabled
    Attempting to move /lib/modules/2.6.18-6-amd64/kernel/drivers/net/r8169.ko to
    /lib/modules/2.6.18-6-amd64/kernel/drivers/net/r8169.ko.bak.
    Blacklisting r8169 in /etc/modprobe.d/blacklist…
    Creating a tmp dir in which to build the module…
    Checking for gcc and linux-headers-2.6.18-6-amd64… OK
    Attempting to build the module…Could not build the module.
    x64etch:/home/egunia/drivers/r8168_scripts#

  93. Doug says:

    “Download this file: r8168_scripts.tar.bz2 – er, or get it onto your computer somehow, since you don’t have a LAN connection atm.”

    Um, that’s my problem. I have the file on a cd rom, but I can’t get it onto the computer. I try mounting the cdrom and it says “wrong fs type, bad option, bad superblock on /dev/scd0, missing codepage or helper program, or other error In some cass useful info i found in syslog – try dmesg | tail or so” I don’t know what any of that means.

    Plus I have a feeling that even once I get the file onto the computer, it still won’t work because “This may fail if you don’t have kernel headers and other standard features of a build environment.” I have no idea if I have kernel headers and other standard features of a build environment (or what those even are), but I do know that if there is a potential problem with no solution spelled out it will effect me and take me hours or days to figure out. Linux is slowly killing me.

  94. Doug says:

    yes. after many hours, I finally got the archive on the computer and ran the script. now it says “checking for gcc and linux-headers-2.6.27-3-server…You need to install package linux-headers-2.6.27-3-server.” Yet another thing I can’t do, because I can’t connect to the internet.

  95. Jameson says:

    Hey Doug,

    Can you mount any CDs? They should just auto mount when you pop them in. To mount a CD-ROM manually, you can try something like:

    sudo mount -t iso9660 -r /dev/cdrom /media/cdrom

    By “standard features of a build environment” I am referring to at least the following packages:

    • gcc
    • linux-headers-2.6.24-19-generic
    • make
    • binutils

    These are required to build the module source. If setting all of that up seems daunting to you, then try to follow the steps on this web page, except don’t build the module. Just use one of the pre-compiled ones found in the tarball. Make sure you use the one that corresponds to your kernel. To figure out what you have, type uname -r. Instead of the “make” lines mentioned above, just copy the module to /lib/modules/`uname -r`/kernel/drivers/net/r8168.ko.

    Linux can be a challenge, but stick with it. You’ll come to a point where it’s not so challenging, you know a hell of a lot about computing, and you get much more out of your system than ever possible with another (closed) OS.

    Good luck,
    Jameson

  96. Doug says:

    Thanks for the encouragement. Its just seems like every time I try to use linux there is some hardware on my system that doesn’t work.
    The mounting problem persisted no matter what -t option I used. Anyway, I got around the mounting problem by using the latest 8.10 alpha release, which someone said works on my system. The network seemed to work long enough for me to install a desktop, and then stopped working and i could not get it to restart, with manual or automatic dhcp. After a couple reboots, I decided to try your script again, and was able to drag it onto the desktop. I, ran it, everything says ok, then says “All done! You should now have a working wired ethernet connection, persistant at boot. Then the network icon on the desktop starts its little animation for awhile, then says network disconnected. I do dhclient eth0, and there is no change still does dchpdiscover and says “No DHCPOFFERS received.”
    In dmesg it says “eth0: Identified chip type is ‘RTL8168C/8111C.” but then says “eth0: RTL8168B/8111B at 0xf89b2000, 00:21:70:14:39:73, IRQ 218″ So is it still loading the wrong driver? I.E. is there a difference between B and C that could be causing a problem?

    grep -E “8168|8169″ /lib/modules/2.6.27-3-server/*returns (… is the path to the modules):
    …/modules.alias:alias pci:v000010ECd00008168sv*sd*db*sc*i* r8168
    …/modules.dep:…/kernel/drivers/net/r8168.ko:
    …/modules.order:kernel/drivers/net/r8169.ko
    …/modules.pcimap:r8168 0x000010ec 0c000008168 0xffffffff 0xf ffffffff 0x000000 0x00000000 0x0

    modprobe -c | grep -E “8168|8169″ returns:
    blacklist r8169]alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168

  97. Doug says:

    by the way, if I try manually setting an ip address, subnet mask, and gateway, I can navigate to my router in firefox, but I cannot connect to the internet, I cannot connect to the other computers through their ip addresses, and I cannot get an ip address automatically.

  98. Jameson says:

    Humph. Well, it looks like I should test this thing out on Intrepid. In the meantime, I’d setup a Hardy install, and try another method of getting the script onto your computer. USB stick? Local network (with static settings)? Just make sure you install the packages I mentioned above (from the installation CD, ostensibly). It’ll probably be a few days until I have time to play around with 8.10 again.

    If the module has been moved from r8169.ko to r8169.ko.bak, then it won’t be used.

    Also, I don’t have a modules.order file – I’m not sure where you got that! (Again, I haven’t tested this in Intrepid.)

    The R8168 is actually the network interface card version. The R8111 is the integrated chip version, which is actually what I have. Since the module is named after the first though, I guess it wins the nomenclature debacle. The difference between B and C can be found on Realtek’s site. To summarize, B supports PCI Express 1.0a, and C supports PCI Express 1.1. My Intel 965 chipset implements the 1.0a spec, so I correspondingly have a R8111b, really. You can check your chipset against this list if you’re unsure. The R8169 family is actually for PCI (non-Express).

    But, it shouldn’t matter in terms of the driver. VastOne (who commented above) reports that this script works for the C, too. So, consider all of this just some “FYI,” if you will.

    Check back soon,
    Jameson

  99. Doug says:

    Thanks for all your help. I’m super busy at work this week, so I won’t have time to fiddle with this until next weekend or possibly the weekend after that. Also, at this point I’m thinking of just picking up a usb ethernet controller, and bypassing the issue entirely.

    I would add for any noobs that look at this in the future that you can add the packages referred to above by typing: “sudo apt-cdrom add” with the installation cd in your drive. Then when you apt-get install it will look for the packages on the cdrom.

  100. Nick says:

    Any ideas why the v8 won’t work but v6 precompiled do? I ask because after going from -19 to -21 I don’t have a precompiled and building manually doesn’t seem to work. It gives the same issue as your precompiled v8 which is that it loads and I see an eth0, just won’t get a link light, odd I know.
    Anyways I enjoy troubleshooting but any pointers would help

  101. Doug says:

    I think part of my problem was installing the desktop on intrepid server. without the desktop intrepid server works out of the box when you set a static ip address. When I install desktop, static ip stops working. I still can’t get an ip address from dhcp either way though. I don’t really need a desktop on this box, and static ip is fine, so I think I’m done.

  102. Jameson says:

    In Intrepid, 2.6.27-4-generic x86_64 GNU/Linux, I’m finding that the default r8169 module is once again working for my Ethernet chip (the 8111B.)

  103. Anupam Gupta says:

    Thanks a lot.
    I was struggling from the last two weeks.

  104. sean says:

    Works great on Hardy – thanks! Do you have a similar one for Intrepid?

  105. Jameson says:

    The 2.6.27-4-generic kernel / modules packages work fine for me out of the box. I did not need to switch out the r8169 module in order to use the 8111b.

  106. Matthias says:

    Your script worked perfect for me under Ubuntu 8.10 Beta with Gigabyte P45-DS3L!

    Thanks a lot

    Matthias

  107. greg says:

    thanks, ive been looking for this for a while. it works just fine w/ R8139.

  108. mattitudeinc says:

    just like to say thanks, this means i can install whatever software i want, hance java, netbeans whatever, thanks!!!! YEY I LOVE LINUX hehe!

    many thanks, hope i can understand linux as much one day!

  109. smartypants says:

    Hey, thanks for the script! it saved me hours of pain of trying to figure out how to get this stupid NIC working.

  110. zhe says:

    Wonderfull works on my Dell Vostro 1310.
    I install Vista and Ubuntu. Ubuntu net not work since installed. After i tuned Nic perferecne in vista such as Wake on lan on and cold reboot it(removed battery), Ubuntu net works for a while and soon failed. pinging just show NETWORK UNREACHABLE.
    I run this script on Ubuntu X64 kernel 19 and reboot, the net works properly.

    Soon I updated the kernel to .21
    Network fails again.
    Run this script and reboot, Network access regained.

    Great Work!
    Thanks

  111. Bertland G.H. Hope says:

    Thank you so much. I am new to Ubuntu and had been having trouble with my internet connection. Now! After using your script I am online and yes sending you this message from the Linux partition. Keep up the good work and i will refer my friends to your website. Many manny mannyy THANKS. N BIG UPS U LARGE!! MR WILLIAMS. ^-^

  112. Bertland G.H. Hope says:

    O by the way i have a HP TX2510us

  113. Kees says:

    Thanks!

  114. Nick says:

    Works on Ubuntu Gutsy/7.10 (2.6.22-15-generic)

    You saved my bacon, karma+1 to you sir! :)

  115. Pablo Bardelli says:

    I successfully used this great script several months ago with hardy.
    Today I updgraded to Intrepid, and the problem keep existing….but I run this wonderful same script and the network eth0 appeared again in just few seconds!!!
    Thank you very much Jameson

    Pablo
    Argentina

  116. Kazooless says:

    Ubuntu Intrepid Server i386 on D945GCLF2 (Realtek 8111c) didn’t have much luck with the script with the newest driver (r8168-8.009.00.tar.bz2) even though I changed the script by changing the 008 to 009 in the script.

    However, I was able to use the manual instructions. Now when doing an ifconfig I see that I am not getting dropped packets.

    Thanks!

  117. Emanuele Pane says:

    Hi,

    I tried many times since the Alpha release of Ubuntu 8.10 to make my onboard ethernet chip work, but never succeeded.
    I opened a bug report here if anyone is interested in contributing: https://bugs.launchpad.net/ubuntu/+source/linux-restricted-modules/+bug/286489
    After a fresh install of Intrepid amd64 it still is not working: I just tried to do manually the instructions above, since last time I tried the script I could make it work. Still no working chip, though.
    I get no errors in any of the steps above.
    This is what I get from grep -E “8168|8169″ /lib/modules/2.6.27-7-generic/*

    /lib/modules/2.6.27-7-generic/modules.alias:alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168
    /lib/modules/2.6.27-7-generic/modules.dep:/lib/modules/2.6.27-7-generic/kernel/drivers/net/r8168.ko:
    /lib/modules/2.6.27-7-generic/modules.pcimap:r8168 0x000010ec 0x00008168 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0

    modprobe -c | grep -E “8168|8169″
    blacklist r8169
    alias pci:v000010ECd00008168sv*sd*bc*sc*i* r8168

    Any suggestion would be so much appreciated!
    Thanks Jameson for addressing this problem,
    Emanuele

  118. Jameson says:

    @Kazooless: I’m glad to hear you got things working. Thanks for letting me know the driver got updated – I have updated the script to work with that driver code. Seems to be working fine with v9 driver on this end.

  119. Jameson says:

    @Emanuele: I’ve had no trouble with the the default r8169 module for 2.6.27-7-generic. With that module, was your Ethernet card not recognized, unable to acquire a dhcp release, or what, exactly?

  120. Emanuele Pane says:

    Hi Jameson,

    the issue is actually quite peculiar (at least for my experience): apparently with both r8169 and r8168 my card is recognized as
    Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02)
    and gets everything assigned from DHCP, but it still does not work.
    I’m starting to wonder if it’s a network-manager problem or some other package after all.

  121. nexuz says:

    Hi Jameson, I’m having the exact same issue than Emanuele,,, not even the script can fix my card… I’ve tried everything… a fresh install without executing the script, executing the script, but the card doesnt want to work right… I get everything assigned from the DHCP, but it still doesnt work. What do you think the problem could be?

  122. Geir says:

    Hi Jameson!
    Thanks alot for the great script!!! It helped med a lot yesterday :-)

    I had some problems, though, getting the card to go beyond 100MBit. Everytime I tried to set it to gigabit speed using both ethtool and insmod as mentioned in the ReadMe delivered with the RealTek driver sources, it shortly tried to connect at that speed, but always fell back to 100Mbit.Reboot didn’t do the trick either.
    Then I thought I had to check if the cable actually lived up to the standard since I had just made it myself. So I connected it to my MacBook, and the 3Com-switch immediately reported a full gigabit. The cable was fine.
    Now, the funny thing is that, when I reconnected the cable to my Ubuntu-box, the switch still reported gigabit. And so did ethtool eth0! Hooray :-) Now it’s both fast and stable.

    So If anyone is having the same problem as I did, try switching ports on the router/switch with a computer that’s running full gigabit. It helped me, for somewhat reason.

    Thanks again, Jameson!

  123. Lex says:

    Hi Jameson!
    I tried your script on my Ubuntu Server 8.10 amd64, but it doesn’t run. The “make modules”
    results in an error “*** No rule to make target `modules’. Stop.” Can you help me with this? Thanks, Lex

  124. […] download r8168 driver r8168 driver install instruction […]

  125. Mark says:

    Worked perfectly. I can’t thank you enough.

  126. Jay says:

    Ugh! This is driving me crazy… I have a Gigabyte GA-EX58-UD5 mainboard, and got the network up and running a week ago, with recompiled r8169 (yes, I think it was the ‘9, but I’m not exactly 100% sure any more) and everything has been honky dory until I unfortunately had to reboot to remove a disk today.

    After removing that (unused) disk, no matter what I do (and I have been trying *a lot of things*) I cannot get any eth0 (or other) device up and running! It is as if the ethernet hardware simply doesn’t exist! Forget about lost packets or slow transfer or other such beautiful nice problems! I get nil. nothing. nada. sigh.

    And *nothing* has changed… same hardware (except the disk,) same kernel (2.6.27-9) and I have tried *all* combinations of r816[89], scripts, patches, different Realtek-driver-versions, depmod-this and mkinitramfs-that, and so on…

    It’s almost as if I’ll welcome those nice strong-looking guys in white when they come to pick me up and take me to that quiet, relaxing place where my mind can rest…

    J.

  127. […] ein BIOS-Update in Kombination mit den aktuellsten Treibern (sprich: einem frischen Kernel oder Herstellertreiber). Das war mir dann zu aufwendig, ich deaktivierte den PXE-Boot und entschied mich für die […]

  128. Bryan says:

    Thank you, thank you, thank you! That worked great for me on 2.6.22-15-generic. Without people like you my Linux days would be over.

  129. chet says:

    Hi Jameson,

    I ran your script and now I don’t have network service. I have the 2.6.24-19-server. Should have read more in detail before I ran it.

    After I ran the script, it prompted me to install a linux header?

    How do I work around this? Please help.

    Thanks.

  130. Jameson says:

    Chet,

    Well, it sounds like you probably didn’t have network service before trying the script either, right? ;-)

    Since you’re trying to compile a kernel module (which makes references to kernel code) you will definitely need the header files for Linux – just think in terms of your days with C, if you try to write printf( "Hello World.n" ); without first having included stdio.h, the printf symbol won’t have been defined. That’s essentially what’s happening tens or hundreds of times when you try to compile a Linux kernel module without the kernel headers.

    So, here’s what you should do:

    1. Find out what kernel you’re running: dpkg -l | grep linux-image-2.6.24-19 | awk '{ print $3 }'
    2. Download the corresponding Linux headers to a USB stick and copy to your Ubuntu machine. (They are appropriately named linux-headers-<version_arch>.deb)
    3. Install the Linux headers package: dpkg -i <package-name-here>.deb
    4. Run my script again.

    It sounds like you probably want linux-headers-2.6.24-19-server_2.6.24-19.34_amd64.deb, but you’ll have to double check that.

    Good luck!

  131. John says:

    Jay,

    I also have the Gigabyte GA-EX58-UD5. When I first installed Intrepid, LAN1 (eth0) would not work at all. LAN2 (eth1) sort of worked, but it kept having long pauses during network access.

    So, I remove r8169 and installed r8168. Now, eth1 is working fine, no more pauses. But eth0 still does not work at all. Odd.

  132. Jeevan says:

    Hi Jameson,

    This script worked like charm. Thank you very much for providing this script.

    – Jeevan

  133. Ariel says:

    John / Jay

    Have been experiencing similar problems with my GA-EX58-UD5 card. Tried the script here but did not seem to fix it.

    Have you found another solution? Have you tried another Linux distro?

    Ariel

  134. wuxiaoyu says:

    hello,

    I have a fedora 9, when I do insmod ./src/r8168.ko, I have these error message:

    -l invalid modules format

    Could you help me ?

    thanks

  135. Arrikhan says:

    running older debian release and receiving same error about invalid module format when attempting to install driver.

    I had to install the source to run make clean modules using an older network card.

    uname shows a diff ver to vermagic in module info. Would this be the cause of the problem?

    uname -r = 2.6.16-2-686

    modinfo shows following ..

    filename: ./src/r8168.ko
    author: Realtek and the Linux r8168 crew
    description: RealTek RTL-8168 Gigabit Ethernet driver
    license: GPL
    version: 8.009.00-NAPI
    vermagic: 2.6.18-6-686 SMP mod_unload 686 REGPARM gcc-4.1
    depends:
    alias: pci:v000010ECd00008168sv*sd*bc*sc*i*
    srcversion: DEFCC4DF8145E8BF674B676
    parm: debug:Debug verbosity level (0=none, …, 16=all) (int)
    parm: use_dac:Enable PCI DAC. Unsafe on 32 bit PCI slot. (int)
    parm: rx_copybreak:Copy breakpoint for copy-only-tiny-frames (int)
    parm: autoneg:force phy operation. Deprecated by ethtool (8). (array of int)
    parm: duplex:force phy operation. Deprecated by ethtool (8). (array of int)
    parm: speed:force phy operation. Deprecated by ethtool (8). (array of int)

    PS: great work with effort in getting this stuff to work .. !

    Arrikhan

  136. Ethan says:

    Well done, my friend, well done.

    I just built a new Hardy machine with a 8111C, and the network interface worked, but the RX dropped packets were growing a huge rate. Your script fixed things right up!

  137. […] Re: Network: RTL8168C Gunter Lindemann wrote: > Hi all! > > Does Ubuntu 8.10 support the network device RTL8168C? > > Gunter > From a quick google search it would appear to but you might want to browse the following url: http://www.jamesonwilliams.com/hardy-r8168.html […]

  138. […] Jamesonwilliams.com och Hardware […]

  139. […] adalah r8169, sedangkan yang dibutuhkan adalah r8168. Solusi pemecahan diperoleh pada situs jamesonwilliams.com. Solusi ini pernah dicoba pada sistem operasi Ubuntu 8.04. Langkah-langkah yang dilakukan adalah […]

  140. Tombo says:

    OMG thanks. I’ve been searching google for a solution to this which included such voodoo as:

    1. Shut down the box, unplug it for 10 seconds while pressing the power button, then plug it back in.

    2. Turn off acpi, acpi=ht, acpi=noirq, etc

    3. Power cycle 10 times or so.

    4. Jump on one leg 3 times while blinking and singing Dixie.

    None of them worked, but this did the trick. Tx a bunch.

    PS mkinitramfs -o /boot/initrd.img-`uname -r` `uname -r` wasn’t found (mkinitramfs) on CentOS 5.2 but it doesn’t seem to matter.

    Again, thanks been at this for 3.5 hrs straight.

  141. neilrsg says:

    Thanks! Everything is working good now.

    I am running ubuntu 8.04.2 amd64 bit desktop on a D945gclf2 intel board with integrated dual core 1.6ghz atom 330 cpu.

  142. paolo says:

    Hello,
    I have an Ubuntu 6.06.2 server (kernel 2.6.22-server) affected by this problem: will your script work anyway?
    thanks,

    Paolo

  143. Jameson says:

    Hey Paolo,

    I suppose it hasn’t been serving much, then? hoho. But yes, if you believe you are having the same problem, my script should work for any distro with a 2.4 or 2.6 kernel and the initramfs-tools package (i.e. for at least all Debian derivatives in recent memory (e.g. all versions of Ubuntu)).

    Best,
    Jameson

  144. paolo says:

    Thanks Jameson,
    I followed your instructions, downloaded the correspondant linux headers, but your script hangs on
    Attempting to build the module… Could not build module

    when installing the generic header for my kernel, I had a perl warning message saying that I hadn’t the right language (i’m using a french system) so it was falling on standard (“C”) but I doubt that would be the problem right?
    In which direction should I investigate?
    Let me add that this system is a customized version of 6.06.2 and so for example, I couldn’t install coreutils as the ones indicated in the linux headers dependencies, as the installed version is older than the minimal required:
    coreutils pre-depends on libselinux1(>= 2.0.15)
    libselinux1 is installed, but is version 1.28-2ubuntu.
    dpkg error processing coreutils….
    pre-dependency problem – not installing coreutils

    any light somewhere?

    thanks,

    Paolo

  145. Jameson says:

    Hey Paulo,

    Well, I suppose I have two recommendations, commensurate with your level of experience.

    If you are new to UNIX/Linux, then my recommendation would be to use a stock distribution on your server — something newer, too. 6.06 has already seen a few seasons. I would recommend in particular Debian Lenny, which was just moved to stable last Sunday.

    If you are not, then I would recommend looking at my switchmods script, and running the important parts manually (or those listed on this page.) Essentially, you want to build the r8168 driver by hand, and watch for a compiler error. My script suppresses the build output, I believe — I haven’t actually looked at it in a while.

    Jameson

  146. Jason says:

    I’ve got a gigabyte mobo with this lan chip. The following problem is occurs on all debian distros. Currently I have a fresh install of Ubuntu 8.10.

    I lose my internet/network connection when downloading at a high rate. For example when running system update, but not when surfing the web.

    I have installed the 8168 module by building it myself, but this did not solve the problem.

    http://www.linuxquestions.org/questions/linux-networking-3/wired-network-disconnect-from-orange-livebox-when-download-speeds-are-fast-706116/

    If you care to comment, it would be great. Thanks!

  147. Jameson says:

    Hi Jason,

    The next time you have the problem, can you check the timestamps for files in /var/log/* and make note of any messages you receive? If you can post them here I may be able to provide more insight on the matter. I have not seemed to have any trouble with r8168.

    Jameson

  148. Nic says:

    Hey,

    Great script, it did exactly what was advertised – unfortunately it didn’t fix my problem with me 8111B. I have integrated Gbit 8111B in my Biostar TF7025-M2 motherboard, running Ubuntu Hardy server.

    I had connectivity when it was using the 8169 driver, but there were problems with the speed. It fluctuated wildly when I’d transfer files over SMB (sometimes 60MB/s+ sustained, other times I could barely get over 5MB/s). Streaming video over SMB sometimes worked flawlessly and sometimes stuttered and was unwatchable.

    I was really excited to think that switching to the 8168 driver may fix my issues, but unfortunately the problem still remains. When I first booted up with the 8168 driver I got transfer speeds of almost 70MB/s sustained. The next day I couldn’t get it to go over 6MB/s.

    Any ideas? Do you have any problems like this?

  149. Jameson says:

    Hi Nic, yours and Jasons are the first reports I’ve heard (or can recall) of this problem. Since I haven’t had the issue, I’d like to pretend that it doesn’t actually exist, but hey — I’ll buy it. I assume your speeds are those benchmarked in a properly operating local area network where no known bottlenecks exist? It could also potentially be an issue with SMB. If it is a problem with r8168, can you check your log files and see if the module is mentioned at all, or if there is anything curious when you are having throughput problems?

    Thanks,
    Jameson

  150. Nic says:

    The only possible bottleneck there could be is the gigabit switch I’m using – I’ll try replacing it tonight and see if anything changes. I’ve also ordered another NIC with a Marvell 88E8001 chipset, if that works then I’ll know it’s the 8111b for sure. Maybe I’ll try to duplicate the problem with FTP tonight to rule out SMB – it’s hard to replicate though since it’s so intermittant.

    Are there any logs should I check specifically? I tried grep r8168 /var/log/* and didn’t see anything suspicious.

    Is there a better way to benchmark network performance over SMB than by copying files back and forth?

    Thanks for the help,

    Nic

  151. Serge says:

    Hello,
    Just a quick note to thank you and to tell you that i ran into this problem and your post and script greatly helped me.
    After my old motherboard … burned, i replaced it with a new one (Asus P5Q), without reinstalling ubuntu (no time for that), everything worked fine except the network … It took me a while to understand what was going on (r8169 still appearing in dmesg log), then finally finding your post and script which worked great. Thanks !

  152. Don Richtenburg says:

    I tried the script but the ftp sites all return “login incorrect” for anonymous login, and I can download the driver.
    Any suggestions?
    Thanks,

    Don

  153. Jameson says:

    Hi Don,

    I can confirm that Realtek has removed the direct ftp access to the Linux drivers for some unimaginable reason — even the links on their site are not working for me. Try the actual script I wrote, that you can download. It does not require any internet connectivity — the Realtek tarball is packaged in my tarball. It sounds like you were just following the “key steps.”

    Jameson

  154. You, sir, are a complete legend. Next time you’re in London (or we’re in Boston) IOU a pint of beer (or other alcoholic or non-alcoholic beverage of your choosing).

  155. Jameson says:

    Hey thanks Dominic! My pleasure. Wish you’d caught me while I was near London. I’ll be out on the Pacific coast next May. Anyhoo, glad I could be of help, and I do hope you get to visit the states sometime soon! Best, Jameson

  156. Justin says:

    Hi Jameson,
    Ive run your switchmods script, done everything manually, but nothing seems to work. There are no traces of 8169 to be found. On each reboot I still get “No network connection”. It appears that my NIC has disappeared completely…any ideas? I should note that this is for Ubuntu 10.8, if that makes any difference. Brand new machine, built about 2 weeks ago. Worked up until 8 hours ago…any help would be appreciated. Might as well downgrade since its known to work there…Thanks in advance!

  157. Jameson says:

    Hi Justin,

    I suppose you mean 8.10 — Intrepid? I’m using Intrepid, and the switchmods script has been working for me. Do you get any error messages when you run the script, or when you try the “key steps”? What does is the output of lspci | grep Realtek

    Also, I’ll be updating this package for the 8.011 driver source later in the day. That shouldn’t affect you Justin, but I figured I might as well post it while I was commenting here anyway!

    Best,
    Jameson

  158. Justin says:

    Hi Jameson,
    Oops, sorry I did mean 8.10 (3:27 AM causes dyslexia). Nothing shows up in lspci, lshw. I’ve grep’d them for anything that could possibly be related to Realtek/8111d/8168/etc etc. The one interesting thing is that when I used your script, everything appeared to work fine and I can do a lsmod | grep r8168 and see that the module is loaded. Reboot, repeat, doesnt find anything. When I tried to compile the 8.011 driver source before I found your script, encountered a few issues with their make-file, which wouldn’t let me install. I would assume the errors are due to either not having the correct kernel-headers or kernel source. It could be a possible hw failure, but before I can say that, I am going to see how my Windows XP Live CD works. Thanks for the help, well appreciated!

  159. Justin says:

    Looks like it is a HW issue. The motherboard, GA-EX58-UD3R is supposedly known to have issues with the onboard lan. I was able to get it to come back up after shutting down and removing the power cord for about 30 seconds. Why it worked, who knows. I think I will be taking this one back…thanks again.

  160. Jameson says:

    I am going to see how my Windows XP Live CD works

    Oh no! Well, hope you don’t see for very long, and that you’ll stay on the winning team!

    It is bad news that it’s not showing up on lspci, though. That does indicate to me that you might potentially have a legitimate hardware issue, but I’ve done little troubleshooting in that arena in the past.

    Best,
    Jameson

  161. mithun says:

    my card is 8101e type. I’m facing similar problem. I try downloading and installing your script which get installed successfully.
    But now it says no such device for eth0. :(

  162. mithun says:

    Hi,
    I downloaded the driver source from realtek site for r8101e (r8101-1.011.00.tar.bz2) and modified the driver source variable to point to new driver source.
    It says could not build modules.

    Thanks,
    Mithun

  163. Jameson says:

    Mithun,

    You caught me on a good day. I was bored and feeling helpful. So I wrote this up for you. Well, really, enough people had asked about it that I thought it might be a good idea to do anyway. Give it a try and see if it fixes your problem. Please post back there.

    Script to Fix R8101 on Debian/Ubuntu GNU/Linux

    Hope it helps,
    Jameson

  164. Mike says:

    I am just getting an error ” could not build module” . Any idea? I am on 9.04 server alfa 6.
    Thanks
    Mike

  165. Jameson says:

    I suspect the Realtek code hasn’t caught up with new kernel in 9.04 alpha 6. I suggest not using an alpha release operating system, or patching the driver yourself.

  166. Steve says:

    It broke !

    Before it broke, I checked lspci, and I have the RTL8111/8168B network chip, as desired. I downloaded your script for that chip, and via a SSH connection to the Ubuntu 8.04.1 server, I ran the script. The network connection died while the script was running.

    I checked a monitor connected to that machine, and I saw this error message:

    You need to install package linux-headers-2.6.24-19-server’.

    But my network interface is now dead. :-(((

    How do I fix this ?

    Thank you.

    — Steve

  167. Steve says:

    I’m following up my frantic plea for help above. The good news is that the machine can connect again to the network when I reboot it. The bad news is that even after I loaded the missing headers, I still can’t install the new drivers.

    Now I get this error message when running the script:

    Blacklisting R8xxx…
    Checking for gcc and linux-headers-xxx… OK
    Attempting to build the module… Could not build the module.

    This is a popular, Intel D945GCLF2 mini-ITX mainboard. The eth0 port “usually” works, at least at the < 1 Mbps data rates I’ve tested it with, but ifconfig shows literally billions of dropped RX packets.

    How do I fix this ?

    — Steve

  168. Jameson says:

    Steve – build the module on your own and see what error message you get.
    Best,
    Jameson

  169. Steve says:

    IT’S FIXED !!!

  170. Steve says:

    it’s fixed !!!

    The problem was that gcc was missing. I used ‘apt-get install gcc’ (with a working network) and now the script runs without errors, AND, there are no longer dropped packets on eth0.

    I suggest the script check for linux-headers and gcc.

    — Steve

  171. Jameson says:

    Steve —

    It already did, but in a casual way via a grep gcc So if you have other gcc-related packages installed but not the actual compiler, this isn’t of much help. Per your suggestion I changed the check to a [[ -f /usr/bin/gcc ]] More to the point.

    And yes, it checks for the headers.

    Best,
    Jameson

  172. Peter Rosberg says:

    I’m more than grateful. If I could buy you a beer (or 10…) I would.
    Ubuntu, I read about the meaning and all of a sudden I’m beginning to have faith in people…
    Jameson, you’re a star.
    //Peter

  173. Jason says:

    Hello,

    Anyone know if the kernel in Ubuntu 9.04 (Jaunty) has any compatibility issues with the Realtek 8111c? I’ve built a NAS from the MSI Wind PC and Jaunty. Everything works but transfer rates on large files are initially around 2MB/sec and gets slower until crapping out about 1 minute into the transfer. I am trying to determine what might be causing this and noticed some Ubuntu users have had probs using Realtek Network cards. Thanks for your help!

  174. Jameson says:

    Hey Jason — I have the 8111b, but yes, the default Jaunty module package still had not fixed my problem. I had to use this script still. Not sure about c — somewhere above is an explanation of the difference, though. I doubt the case is any different.

  175. […] the source code — essentially the plans — for the driver, and that someone else had already produced a fix.  I downloaded the fix, opened it up and read it, because I can do that, to make sure that there […]

  176. Zia says:

    Hi,
    This script worked a treat on ubuntu v8.10 with Asrock x58 motherboard which had onboard R8111DL nics.
    Looks like it was recently updated also (last updated march 18, 2009).
    Thx James!

  177. Zia says:

    Can anyone offer any thoughts to a script of this nature for SUSE v11? SUSE v11 seems to be suffering the same problems.
    Thanks.

  178. Manowar says:

    This fix worked (after a lot of trial and error since I am new) on Ubuntu 8.10. I did a 100% clean install of 9.04 and strangely the wired connection will work for a few days and then drop out, and maybe come back a few days later. I am reluctant to try this patch again given the somewhat odd state my system is in……anyone have Ubuntu 9.04 experience with an r8168 in an HP laptop?

  179. Dominic says:

    Jameson,
    I have a GigaByte GA-EX58-Extreme motherboard and the onboard LAN won’t work in Ubuntu 8.10 64 bit. It works fine in Windows. If I bootup in Intrepid they just won’t show up and the next time I need to turn my PSU off for Windows to find the NIC again…
    So, I guess the bug is still there in 8.10. In Jaunty it works perfectly but I want to keep my 8.10. My board uses 2x Realtek 8111D chips. Could your script work for me? If not, could you please help me adapt it?
    Thanks a million!!!

  180. Jameson says:

    Dominic —

    Yes, I and many others have used this successfully with Intrepid. Give it a go!

    — Jameson

  181. Alastriona says:

    Thanks a bunch for this! I have the MSI AMD 770-C45 mobo which comes with an unsupported ethernet adapter. I was struggling for a while but your script instantly fixed it for me.

  182. Soan says:

    Thanks so much, This worked for us.

  183. David says:

    I just upgraded my ubuntu system to the “2.6.28-14-server” kernel. Now when I try to compile the driver I get:

    /share/Atom/kernel/r8168/r8168-8.012.00/src/r8168_n.c:6020: error: implicit declaration of function âpci_module_initâ
    make[3]: *** [/share/Atom/kernel/r8168/r8168-8.012.00/src/r8168_n.o] Error 1
    make[2]: *** [_module_/share/Atom/kernel/r8168/r8168-8.012.00/src] Error 2
    make[2]: Leaving directory `/usr/src/linux-source-2.6.28′
    make[1]: *** [modules] Error 2
    make[1]: Leaving directory `/share/Atom/kernel/r8168/r8168-8.012.00/src’
    make: *** [modules] Error 2

    This I was able to compile the driver under the 2.6.28-13-server build.

    Thanks!

  184. Nielsen says:

    Jameson !

    Thanks so much, r8101 patch on DEBIAN lenny kernel 2.6.26-2 WORK perfect, after reboot…

  185. jono says:

    I tried your script and I am still having no luck with this NIC…

    I have an R8111C in the gigabyte GA-EP45-UD3L motherboard. I’m running 2.6.28-11-generic i686 GNU/Linux with ubuntu 9.04 jaunty jackalope. I ran your script to try to switch to r8168 and it still did not help. ifconfig still does not see any eth0… the script output said everything was okay and I did a lsmod and it says the 8168 is the installed module… I then tried downloading the latest drivers. (yours are the 009 I tried it with the 013). I edited the script to use the new drivers but I still have no luck! I don’t know what else to do. Anyone have any ideas?

  186. Maciek says:

    I have RLT8111DL, lsmod says the 8168 is the installed module, and it still have no work.

  187. NewtownGuy says:

    The procedure seems to have broken or I’m now doing something wrong…

    I’ve done this procedure deveral times before with same everything (Ubuntu Server LTS 8.04 — 2.6.24-19-server i686 GNU/Linux) and the same Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02), and Intel mini-ITX motherboard (Little Valley 2), but it doesn’t work anymore.

    When I run ./switchmods, it seems to run fine. It reports that gcc and headers are OK, but then it reports that it failed to build the modules. At that point, ifconfig eth0 doesn’t exist anymore, although eth0 does come back the old way if I cycle the power (as opposed to just rebooting.)

    Any suggestions ?

    Thank you.

  188. […] some more Google searches I found that Linux support in general was poor for this chipset but fixable as Realtek gives you the sources for the drivers so it should be possible to hack in support for it […]

  189. […] but there is not eth0. …perhaps I have tried all the tips I found about that at web… such as: Script to Fix R8168 and R8111 in Debian/Ubuntu GNU/Linux Now I get back, with the standard SUSE 11.1 installation with the following details: […]

  190. nick says:

    Another guide to solve this problem under Debian Squeeze is available at
    http://bernaerts.dyndns.org/linux/49-debian-server-rtl8111

  191. Mike says:

    Works fine under Jaunty except that /etc/modprobe.d/blacklist is now /etc/modprobe.d/blacklist.conf. Also, version 8.014.00 is now out from Realtek.

    http://www.realtek.com.tw/DOWNLOADS/downloadsView.aspx?Langid=1&PNid=13&PFid=5&Level=5&Conn=4&DownTypeID=3&GetDown=false&SortByDesc=1#2

  192. Charles says:

    Dear Jameson,

    First, I wanted to thank you and applaud your support of what is obviously a frustrating problem for many! Thank you thank you!

    I am a complete Linux noob, and had been working on this problem for hours when I came across your solution. I am trying to get trixbox CE v2.8.0.1 going on a Gigabyte GA-945GCM-S2C motherboard with RTL 8101E chip (10/100 Mbit). The challenge is when I run your script, I get the following

    Checking for gcc and linux-headers-2.6.18-128.1.10.el5. . . ./switchmods: line89: dpkg: command not found
    You need to install package linux-headers-2.6.18-128.1.10.el5.

    I have installed gcc from the CentOS 5.3 installation DVD. I have also installed the kernel-devel package using yum against the CentOS 5.3 DVD mounted as repository. I have also tried to verify installation of headers by running the following

    yum –disablerepo=* –enablerepo=c5-media -y install kernel-headers*

    and get

    Package matching kernel-headers-2.6.18-128.el5.i386 already installed. Checking for update.
    Nothing to do.

    I have tried compiling manually following the instructions in the readme with the driver, but get


    make[1]: Entering directory ‘/tmp/r8101-1.013.00/src’
    make -C /lib/modules/2.6.18-128.1.10.el5/build SUBDIRS=/tmp/r8101-1.013.00/src modules
    make: Entering an unknown directory
    make: *** /lib/modules/2.6.18-128.1.10.el5/build: No such file or directory. Stop.
    make: Leaving an unknown directory
    make[1]: *** [modules] Error 2
    make[1]: Leaving directory ‘/tmp/r8101-1.013.00/src’
    make: *** [modules] Error 2

    When I browse to /lib/modules/2.6.18-128.1.10.el5 I see directories “build” and “source” blinking in white letters on a red background, which I understand to mean that the file or directory is no longer there anymore.

    I have searched through your comments, and apologize if I have overlooked your answer to a similar problem.

    Thanks for any help or suggestions,
    Charles

  193. Charles says:

    Dear Jameson,

    I just wanted to let you know that I was able to resolve my problem by following the below directions, in case anyone else is having difficulty with their trixbox installation on CentOS with the Realtek rs8101E LAN port.


    Once trixbox CE has been installed on the
    appliance you will then be able to install the appliance setup script
    which located at /var/appliance_load/setup-appliance.sh

    Sincerely,
    Charles

  194. Jameson says:

    Note: this workaround does not appear to work for Ubuntu 9.04 (Jaunty.) The default r8169 module has finally been fixed in 9.10 (Karmic (Kernel 2.6.31)), though!!

    Also, the v13 and v14 r8168 code currently does not compile on Karmic because of a change that was introduced in kernel 2.6.31. The net_device structure has been modified, and the Realtek driver source will need to be (minimally?) adapted.

    Best,
    Jameson

  195. Luca says:

    Hi, I have ubuntu server 9.04 64bit edition, and when i try to execute:
    sudo ./switchmods
    sudo: unable to execute ./switchmods: Permission denied.

    What is the problem?
    I try sudo chown myuser:myuser ./switchmods but do nothing and then if i try again sudo ./switchmods i receive the same error.

    Thanks.

  196. Jameson says:

    Luca, as stated directly above, it probably won’t work for you anyway. As for your problem: you appear not to have executable privileges for the file or you are trying to run it from a filesystem that has been mounted noexec.

  197. Jameson says:

    Note: I have created a patch for the r8168 code for kernels >=2.6.31 It resolves the change in the net_device structure. In other words, you will need to apply this patch to the v14 Realtek source before it will compile on distros like Karmic (>= 2.6.31.) Enjoy!

    Here’s the patch.

    I have also updated my scripts package to apply the patch. I also mailed it to Realtek. Hopefully they’ll put the changes into v15.

  198. stephanie says:

    I have tried installing ubuntu 9.04 and 9.10 and both i have had the same situation with. I am unable to get the ethernet to work. I have 2 Realtek RTL8110SC GbE.

    The drivers it comes with dont seem to work. I want to run your script but on both versions of ubuntu i get:
    ‘Attempting to build the module…could not build module.’

    Others with the same error have posted and the reply was to update a patch or install gcc. In the script it does say ‘Checking for gcc and linux-headers-2.6.31-11-generic… OK’

    However untill I get this working I have no internet connection so I can’t patch or update.

    I do have another windows PC with internet connectivity. Can you tell me how to proceeed with ubuntu having no connection and 1 windows pc that does.

    If necessary i’ll switch back to 9.04 since 9.10 is still in beta until next week.

  199. Jameson says:

    Hi stephanie,

    The module builds fine for me on 9.10 with my new patch (switchmods handles this automatically.) Furthermore, it built fine on 9.04, but wasn’t functioning properly when inserted into running kernel code. (Incidentally, that’s the only debian/ubuntu version i’ve come accross for which this method doesn’t work.)

    Try manually building the driver and seeing what output you get. If the script says you have gcc and linux-headers, then you do. Best, Jameson

  200. Miguel says:

    Hello!

    in switchmods you need to replace

    patch < $RUNPATH/$PATCHFILE
    with
    patch < $PREVWD/$PATCHFILE

  201. Jameson says:

    Thank you Miguel! I haven’t actually run the damn thing myself since my last round of changes — just apparently made some quick cowboy edits. :-) The fixed version is up.

  202. diego says:

    Hi Jameson!
    I hope you are not bored answering question. It’s the first time I write you.
    I have Hardy 8.04 and changed my mini-itx mother board from a Atom 230 to an Atom 330 ASROCK A330GC Mini itx mother board.
    I run your script and had no errors, but lan didn’t work . I tried to reboot, but didn’t work. No eth0 in ifconfig !
    I tried also to substitute the generated ko ( /lib/modules/$(uname-r)/kernel/drivers/net/r8168.ko ) with your precompiled r8168.ko.8.19-generic but han no success!

    uname -rmo

    2.6.24-19-generic x86_64 GNU/Linux

    lspci

    Ethernet controller: Realtek Semiconductor Co.,
    Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev ff)

    Please help! Could be something related to ethernet controller revision? ff could be too new?
    Thanks in advance, Diego

  203. DanielZ says:

    Hi Jameson!
    Your Script work very fine in Ubuntu 9.04 since a long time. Every update I must run your Script that i had a Networkconnection.
    Now i have update to Ubuntu 9.10 and the Networkconnection dosen´t work. I tried to run your script but it doesn´t work in Ubuntu 9.10. Do you update your Script for the new Ubuntu Version?? PLEASE HELP!! Your Script was the best.
    Big THX

  204. thomas says:

    Yes, I have the same problem. Seems like the driver can’c compile in Ubuntu 9.10 anymore, probably due to some changes in 2.6.31.
    I’d be really happy if you could update your script, since I have to use the old kernel right now (which brings problems on other fields…)

    Cheers,
    Thomas

  205. Jameson says:

    Guys, I added a patch for 2.6.31 a couple weeks ago and it compiles and works fine for me on 2.6.31. Look above. Please provide some output if you disagree. Furthermore, the stock r8169 was working for me on 2.6.31 anyway. If you’ve updated to 9.10 from a system that was using r8168, be sure to remove the blacklist line from the modprobe conf and regen your initrd. I am currently not using this as r8169 is working for me now.

  206. Nynn says:

    thank for this script… working well on Jaunty 9.04 (as said ) i can add it’s running under x64 too if some was wondering about :)

    best wishes and regards !!!

  207. Kousik says:

    I have a problem in one particular system. I install everything without any error but still unable to ping my gateway ip address.
    #lspci | grep -i eth
    02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02)
    #modinfo /lib/modules/2.6.22-3-486/kernel/drivers/net/r8168.ko
    filename: /lib/modules/2.6.22-3-486/kernel/drivers/net/r8168.ko
    version: 8.014.00-NAPI
    license: GPL
    description: RealTek RTL-8168 Gigabit Ethernet driver
    author: Realtek and the Linux r8168 crew
    srcversion: BC02C0F47770762AF13C956
    alias: pci:v000010ECd00008168sv*sd*bc*sc*i*
    depends:
    vermagic: 2.6.22-3-486 mod_unload 486
    parm: speed:force phy operation. Deprecated by ethtool (8). (array of int)
    parm: duplex:force phy operation. Deprecated by ethtool (8). (array of int)
    parm: autoneg:force phy operation. Deprecated by ethtool (8). (array of int)
    parm: rx_copybreak:Copy breakpoint for copy-only-tiny-frames (int)
    parm: use_dac:Enable PCI DAC. Unsafe on 32 bit PCI slot. (int)
    parm: debug:Debug verbosity level (0=none, …, 16=all) (int)

  208. […] graphics card didn't even work, but now they work flawlessly. Check this for your Realtek card: Script to Fix R8168 and R8111 in Debian/Ubuntu GNU/Linux check this for the wireless card: HOWTO: Broadcom 4318 Wireless Cards – Ubuntu Forums Also, as […]

  209. Fenno says:

    Thank you so much!!! Thanks to your script I have Ubuntu 9.10 with Gigabit connection!

  210. Robert Aspell says:

    Fixed my problem with lan disconnect on asus m4a785td m evo with ubuntu studio 9.10 Kernel Linux 2.6.31-9-rt. Thank You for your work.

  211. houms says:

    Jameson Thanks a lot for posting this, however this problem still remains for me in Jaunty. Using Dell Vostro 1520 with the
    08:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 03)
    I could always connect via manual or dhcp, but the problem has always been throughput. This card will work for like 10seconds and then transfer rates slow to a complete crawl. I ran your script and it went fine. The r8169 is not loaded and the r8168 is now loading at boot, but the transfer rate is still the same? any ideas?
    thanks again and thanks in advance for any suggestions on this one….

  212. Steve says:

    I’ve got this problem with an interesting twist. I’m loading the driver from a boot server, (our motherboard just started using a new version of the realtek chip that won’t work with the r8169 driver) the problem is that the clients are setup read only so while I have read write access to the actual files from the boot server I can’t just run things like “make install” and such, because it would affect the wrong image. My boot server doesn’t even have a Realtek NIC.
    The guy that set this up for us is gone so we’re having to learn it on the fly. We’re running kernel 2.6.18-6-amd_64 GNU/Linux

    Can anyone help me?

  213. Henry says:

    I’m using r8168-8.018.00, is it still need a patch? Because the NIC still up & down in random.

  214. Gryph says:

    I’m using 2.6.32-25-generic x86_64 GNU/Linux and had the recurring 8169 driver with its issues even after a long-winded manual removal/replacement, as I was without the blacklist.

    I thank you for the above script, it works a treat for the rtl-8168c and in only a few seconds!

    Gryph

  215. Jay says:

    I installed Mepis 8.5 on an MSI 790FX-GD70 which has dual RealTek 811 LAN chips. In order to install your patch, I had to find the repositories, download and install linux-headers and gcc files, six different files in all. Finally, your patch installed. I rebooted, and I still had no internet connection. Thanks for your efforts, though. Is there any distro that works with this chip upon installation? MSI claims to have a Winki version of the motherboard that works Linux natively. I’m skeptical.

  216. Jon says:

    James,
    My OS is Debian Lenny 5 2.6.26-2.686, My NIC is RTL8111/8168B and when i’ve tried to install, i get this error message: cannot stat /etc/modprobe.d/*.conf: No such file or directory
    Could you help me, please?

  217. Erik says:

    Thank you!

  218. nicolas roy says:

    Hej !
    Thank you for the informations. I follow the instructions and the drivers seems to be installed.
    But a DL test shows a speed of 130Mb, whereas the same test under windows shos 600 Mb.
    Any idea ?

    nicolas

  219. Jameson says:

    Hi Nicolas,

    You could try modifying the script to use the latest Realtek release (cureently 8.025.00), or use a more recent Linux with patched in support.

    Best,
    Jameosn

  220. […] ifconfig check the routing table. Also – pick a distro: the one that you normally like which gets the most of the hardware going. This will let people trying to help you focus on specifics. It's no good trying to give you something to try only to find that you have changed install overnight. Have a look at: http://www.jamesonwilliams.com/hardy-r8168 […]

  221. al says:

    “UPDATE: Realtek has removed direct access to the source tarballs”

    Code is here: https://code.google.com/p/r8168/downloads/list

    Also, an explanation for this bug, and some other fixes:
    https://wiki.archlinux.org/index.php/Configuring_Network#Realtek_no_link_.2F_WOL_issue

  222. […] するとScript to Fix R8168 and R8111 in Debian/Ubuntu GNU/Linuxというサイトがヒットし、スクリプトを走らせることで正常認識するようになるらしい。 さっそくr8168_scripts.tar.bz2というファイルをダウンロード。 home直下に解凍すると「r8168_scripts」というディレクトリができる。 12cd r8168_scripts sudo ./switchmods […]

  223. […] Just build in from source. Here are outdated instructions for Ubuntu — there will be a few changes for Redhat. http://nosemaj.org/hardy-r8168 […]

  224. jack says:

    Hi, using server 11.10. installing a second eth (on board has one). when i rmmod r8169 that killed the on board. i guess it’s the same chipset. interesting that oneworks but the second one won’t

  225. Anotonio says:

    root@vshadow r8168_scripts# ./switchmods
    Attempting to remove running r8168 and r8169 modules if loaded…
    Attempting to move /lib/modules/3.8.1-201.fc18.x86_64/kernel/drivers/net/r8169.ko to /lib/modules/3.8.1-201.fc18.x86_64/kernel/drivers/net/r8169.ko.bak.
    Blacklisting r8169 in /etc/modprobe.d/blacklist…
    Creating a tmp dir in which to build the module…
    Checking for gcc and linux-headers-3.8.1-201.fc18.x86_64…dpkg-query: failed to open package info file `/var/lib/dpkg/status’ for reading: No such file or directory
    You need to install package linux-headers-3.8.1-201.fc18.x86_64.

    root@vshadow r8168_scripts# yum install kernel-headers.x86_64
    Loaded plugins: fastestmirror, langpacks, presto, refresh-packagekit
    Loading mirror speeds from cached hostfile
    * fedora: mirrors.med.harvard.edu
    * rpmfusion-free: mirror.us.leaseweb.net
    * rpmfusion-free-updates: mirror.us.leaseweb.net
    * rpmfusion-nonfree: mirror.us.leaseweb.net
    * rpmfusion-nonfree-updates: mirror.us.leaseweb.net
    * updates: mirrors.med.harvard.edu
    Package kernel-headers-3.8.1-201.fc18.x86_64 already installed and latest version
    Nothing to do

  226. Jameson says:

    @Antonio — thanks for the report. However, this page is several years old, and was not written with Red Hat family (let alone fc18 which sounds very recent) in mind. If you can hunt down a solution, I will include your patch in the script.

  227. Antonio says:

    James, Thanks for writing
    The problem is in the kernel
    kernel 3.X

    If you are using the 3.0 kernel will notice that the file / src / Makefile has a bug that causes it to install the file instead of the file r8168.o r8168.ko. After running the autorun.sh put this in the terminal:

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

    Have an excellent product in spite of the years and this problem is not solved in a modern kernel

  228. […] As you can see this method can be a bit convoluted, but it works. I personally didn’t have a problem updating my kernel version, so I chose the next solution. For a more in depth solution, check here. […]

  229. Lucas says:

    Hi, when I shut down my computer and turn it back on again the ethernet doesnt work anymore and to get it to work again I have to do this again: mv /boot/initrd.img-$(uname -r){,.bak}
    mkinitramfs -o /boot/initrd.img-$(uname -r) $(uname -r)

    Is there a way I can set my computer to boot like that in the first place?

  230. Farrukh says:

    Hi mr. Jameson I trying to install RTL8111/8168B PCI Express Gigabit Ethernet controller (rev6) about 3 days. but still have not working many errors. otherwise my Os is SLES 10 sp3 from Novell. I download all things found about it that it is impossible to insert. apt-get command is not present. what I have to do to solve this my comp is Optiplex3010

  231. Jameson says:

    @Farrukh: I don’t know much about SLES. But apt-get is the Debian package manager — it is called ‘zypper’ in the SuSE world. Also, this page is very old. Make sure you’re downloading the latest driver sources from Realtek: http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&PNid=5&PFid=5&Level=5&Conn=4&DownTypeID=3&GetDown=false#2

  232. John Paul says:

    Hi Jameson,
    Kudos for sticking with the page after so long! I’m hoping you can help me with this. When I install the drivers for this card from the Realtek website (r8168-8.037.00) via the autorun.sh, the network begins working immediately. However, after a reboot, it becomes once again inactive. I find myself re-running the autorun.sh in order to connect. My system is Linux Mint 16 64 bit. Is there something I can do to make this “stick” throughout reboots? Thanks!

  233. Jameson says:

    @John: autorun.sh is a newly added thing, it looks like. Looking briefly through it, it looks like it does very similar, but not identical stuff to what I document on this page.

    Did you try my script?

    Also, use lsmod to check and see if r8169 or r8168 modules are loaded at time of next reboot.

  234. John Paul says:

    Hi Jameson,
    Thanks for the quick reply! When I try your script I get:

    fnstein@MintCreature ~/r8168_scripts $ sudo ./switchmods;
    [sudo] password for fnstein:
    Attempting to remove running r8168 and r8169 modules if loaded…
    Attempting to move /lib/modules/3.11.0-12-generic/kernel/drivers/net/r8169.ko to /lib/modules/3.11.0-12-generic/kernel/drivers/net/r8169.ko.bak.
    Blacklisting r8169 in /etc/modprobe.d/blacklist…
    Creating a tmp dir in which to build the module…
    Checking for gcc and linux-headers-3.11.0-12-generic… OK
    Attempting to build the module…Could not build module.
    fnstein@MintCreature ~/r8168_scripts $

    Another odd thing: after reboot, although the network is not working, lsmod gives me this:

    Module Size Used by
    r8168 261295 0

  235. John Paul says:

    OK, now this is funny. On the offchance I tried stopping and starting the network-manager service. Once I started it again, it would immediately connect. If I don’t do that, it just tries to connect endlessly. I tried re-installing network-manager, but to no avail.

  236. John Paul says:

    Ok, I thought I’d post one last thing as I seem to have resolved this myself. For me, it doesn’t look to have been a driver issue per se, the driver installed as the above outputs indicated. My issue was moreso with network-manager. I replaced it with Wicd, and everything appears to be smooth sailing now. I don’t know if this will help anyone else, but I hope that it will.

Leave a Reply