2.5G Ethernet LINUX driver r8125 installation guide

20,329

Solution 1

To avoid having to reinstall the driver after every kernel update, create a file called dkms.conf in the NIC's source directory with these lines:

PACKAGE_NAME="r8125"
PACKAGE_VERSION="9.003.05"
BUILT_MODULE_NAME[0]="$PACKAGE_NAME"
DEST_MODULE_LOCATION[0]="/updates/dkms"
AUTOINSTALL="YES"
REMAKE_INITRD="YES"
CLEAN="rm src/@[email protected] src/*.o || true"

Modify 9.003.05 to the version number that you have the source code for. To install the driver for the first time:

sudo cp -R /path.to/source/ /usr/src/r8125-9.003.05
sudo dkms add -m r8125 -v 9.003.05
sudo dkms build -m r8125 -v 9.003.05
sudo dkms install -m r8125 -v 9.003.05

To update the version, remove the current one first, remembering to change to the correct version number:

sudo dkms remove r8125/9.002.02 --all
sudo rm -rf /usr/src/r81259.002.02/
sudo dkms status

After the first install, dkms will automatically build and install the driver for you. You will, of course, need dkms installed first.

Solution 2

Somehow stuff breaks if I use the config from @nospam. The following config works for the newest versions, I added the kernelver to the build

$ cat dkms.conf
PACKAGE_NAME="realtek-r8125"
PACKAGE_VERSION="9.005.01"
BUILT_MODULE_NAME[0]="r8125"
DEST_MODULE_LOCATION[0]="/updates"
BUILT_MODULE_LOCATION[0]="src"
MAKE="'make' KVER=${kernelver} BSRC=/lib/modules/${kernelver} all"
AUTOINSTALL="yes"
REMAKE_INITRD="yes"
CLEAN="rm src/@[email protected] src/*.o || true"

Solution 3

  • Obtain file from Realtek here (They make it very complicated :-( )
  • Unzip
  • In terminal, change into directory and run sudo ./autorun.sh
Share:
20,329
Ayush Srivastava
Author by

Ayush Srivastava

Updated on September 18, 2022

Comments

  • Ayush Srivastava
    Ayush Srivastava over 1 year

    I have purchased a new desktop and I am trying to run Ubuntu in dual boot with windows 10. I have disabled secure boot and windows fast boot. When I log in to Ubuntu it does not connect to internet via ethernet cable.

    sudo lshw -C network Shows realtek driver is unclaimed.

    The solution I have searched is to install r8125 driver but I just cannot get the steps accurately. Request to let me know what are the installation steps of installing r8125 driver and run the internet from ethernet cable.

  • Rob Cranfill
    Rob Cranfill over 3 years
    I did this but now whenever I update my system, I lose this install (and thus also lose network access) and have to run the ./autorun again. (It goes faster, of course, since it doesn't have to do the cofig and compile steps again, but still.....) How do I make this update "stick"?
  • Ayush Srivastava
    Ayush Srivastava over 3 years
    @RobCranfill you can add ./autorun command to bashrc or crontab to execute it automatically on each system startup.
  • Rob Cranfill
    Rob Cranfill over 3 years
    I don’t think re-building on every startup is the most elegant solution, but thanks for the thought. The new comment detailing the use of DKMS seems more appropriate.
  • Terrance
    Terrance about 3 years
    This works great! +1 However, you might see a warning when running dkms status about the installed version being different than the built version. If you do, just run sudo dkms uninstall -m r8125 -v 9.003.05 -k <kernel version>-generic && sudo dkms install -m r8125 -v 9.003.05 -k <kernel version>-generic --force
  • Tobias Geisler
    Tobias Geisler almost 3 years
    It didn't for me; what worked was this answer (on LZS 20.04): askubuntu.com/a/1289417
  • cdahms
    cdahms almost 3 years
    I just got a new Alienware Aurora R12 with a Killer E3100G 2.5 GB Ethernet Controller and with the 5.8 kernel a stock Ubuntu 20.04 install did not recognize it, this answer worked perfectly to resolve the concern, how I'm the first upvote for this life saver of an answer I'm not sure.
  • Daniel Hansson
    Daniel Hansson almost 3 years
    Thanks for this great fix! I ended up scripting it, and this is the result: github.com/nextcloud/vm/blob/master/network/asusnuc/pn51.sh
  • robvdl
    robvdl almost 3 years
    Tobias you are correct, it didn't work for me either but I didn't find out till later which is why I am updating this post. What seems to have happened is I was using an older kernel on 18.04, compiled the network driver, it said it failed but apparently didn't. Then I upgraded to 20.04, it appeared to work, until I got my first kernel update and then it was back to square one. I believe 22.04 will be the first Ubuntu LTS to properly support 2.5G ethernet out of the box, meanwhile compiling the driver is the only option.
  • Barnaba
    Barnaba almost 3 years
    Thanks, your version also works with 9.005.06, while @nospams would not build.
  • rlhelinski
    rlhelinski over 2 years
    If using a newer version see answer from Martijn askubuntu.com/a/1336708/253486
  • Admin
    Admin almost 2 years
    Note, that the "NIC's source directory" is not the src directory in the the extracted driver folder, but the one that contains the src directory, the Makefile etc.
  • Admin
    Admin almost 2 years
    Even this... It works for a while then after a kernel update dkms status shows r8125, 9.009.01 is installed, but the network card is again unclaimed, and doesn't work... It's incredible that making basic Ethernet work can be so demanding on Linux...