Script to Fix R8168 in Ubuntu Hardy

( Also available in Spanish. )

The Realtek r8168 network card does not work out of the box in Hardy. Instead of r8168, modprobe loads the r8169 module, which is broken. A solution 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. Both methods are working with 16,17,18,19,21-generic (x86_64) kernels, and all relevant files can be downloaded at www.jamesonwilliams.com/bin/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.

My Setup

This problem affected (at least) my setup, which is:
bash$ lspci | grep Ethernet
07:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 02)
bash$ uname -mro
2.6.24-21-generic x86_64 GNU/Linux

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.
wget ftp://210.51.181.211/cn/nic/r8168-8.009.00.tar.bz2
tar xjf r8168-8.009.00.tar.bz2
cd ./r8168-8.009.00

# 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 "\nblacklist r8169\n" >> /etc/modprobe.d/blacklist
mv /lib/modules/`uname -r`/kernel/drivers/net/r8169.ko \
   /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` /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

Realtek RTL8168/RTL8111 driver download locations:

Some useful threads on the topic:

Tags: , , , , , , , , , , , , , , , , , ,

124 Responses to “Script to Fix R8168 in Ubuntu Hardy”

  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 which will decompress the tarball.
    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. 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.

  13. 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 :)

  14. jody Says:

    ok problem solved, it was just a permission problem :) thx 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. jf Says:

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

    shudown -r now

    should be

    shutdown -r now

  20. 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

  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 0×000010ec 0×00008168 0xffffffff 0xffffffff 0×00000000 0×00000000 0×0

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

  23. 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 0×000010ec 0×00008168 0xffffffff 0xffffffff 0×00000000 0×00000000 0×0

    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

  24. 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

  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. Jameson Says:

    Wulp, here’s one:
    http://changelogs.ubuntu.com/changelogs/pool/main/l/linux/linux_2.6.24-18.32/changelog

  28. Roti Says:

    Thanx a lot, it saved my time!
    Roti

  29. 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?

  30. Jameson Says:

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

  31. 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. :(

  32. 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.

  33. 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???

  34. 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

  35. 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.

  36. Jarle Thorsen Says:

    Found a small bug in switchmods:
    echo “\nblacklist r8169\n” >> /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 r8169\n” >> /etc/modprobe.d/blacklist

  37. Jameson Says:

    Yikes. Good call.

  38. Brendan Says:

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

    Thanks dude.

  39. 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.

  40. Jameson Says:

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

  41. 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

  42. 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.

  43. 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

  44. 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/)

  45. 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

  46. 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

  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. VastOne Says:

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

    Can blame a rough morning but I wont!

    Thanks!

    V1

  49. 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.

  50. Jameson Says:

    Luis,

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

    Jameson

  51. 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)

  52. 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

  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. 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

  55. 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!!!

  56. 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

  57. 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!!!

  58. 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?

  59. 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.

  60. 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

  61. 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

  62. Tomek Says:

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

    Best,
    Tomek

  63. 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

  64. 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

  65. 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

  66. 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

  67. 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.

  68. 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

  69. 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.

  70. 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.

  71. muhdazmil Says:

    thank your 4 the solution

  72. Dave Says:

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

  73. Don Says:

    The script worked perfectly on a Dell Studio Hybrid.

  74. 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!

  75. Joe Says:

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

  76. meatric Says:

    many thanks, work succesfully!

  77. 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 :(

  78. Refrigerator Says:

    i have a Vostro 1310 btw.

  79. 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.

  80. 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

  81. Jameson Says:

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

  82. 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

  83. 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.

  84. 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

  85. CreativeThings Says:

    Hi,

    thanx!
    Your script works like a charm!

    regards,
    Niels

  86. 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

  87. 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

  88. 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

  89. 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.

  90. 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.

  91. 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!!!!!!

  92. 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

  93. 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#

  94. 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.

  95. 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.

  96. 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

  97. 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 0×000010ec 0c000008168 0xffffffff 0xf ffffffff 0×000000 0×00000000 0×0

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

  98. 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.

  99. 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

  100. 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.

  101. 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

  102. 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.

  103. 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.)

  104. Anupam Gupta Says:

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

  105. sean Says:

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

  106. 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.

  107. Matthias Says:

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

    Thanks a lot

    Matthias

  108. greg Says:

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

  109. 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!

  110. 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.

  111. 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

  112. 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. ^-^

  113. Bertland G.H. Hope Says:

    O by the way i have a HP TX2510us

  114. Kees Says:

    Thanks!

  115. Nick Says:

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

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

  116. 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

  117. 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!

  118. 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 0×000010ec 0×00008168 0xffffffff 0xffffffff 0×00000000 0×00000000 0×0

    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

  119. 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.

  120. 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?

  121. 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.

  122. 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?

  123. 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!

  124. 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

Leave a Reply