# Realtek RTL 8125 2.5Gbps LAN controller.



## JMOR (Apr 7, 2021)

Let me apologize upfront if this is too much of a basic question. Sure there are enough resources out there for me to figure this one out by myself. But, I am complete newbie to BSD Unix, and some guidance may help me to speed up the process.

I am trying to install FreeBSD (13.0) in my new PC but I am missing the very important Ethernet driver, hence no connection to Internet. I have a _MSI X570 Unify_ motherboard which comes with a _Realtek RTL 8125 2.5Gbps LAN controller_. (Additionally to a _Intel Wi-Fi 6 AX200_ connection, but I am not even looking at this yet)

I am thinking in copying the driver into the USB installer, some directory in either memstick.img or mini-memstick.img (preferably the later, but it won't have the base system nor way to access the Internet to get it - NIC not recognized). Then proceed with the installation as per the HandBook, afterwards copy the driver I put in the installer into the just installed base system, do some magic, and hopefully after rebooting I would be able to access the network card.

Am I wrong or am I wrong? Anyway, some directions would be appreciated.

By the way, I think this is the driver I should be using: realtek-re-kmod (Kernel driver for Realtek PCIe Ethernet Controllers from FreshPorts). But, it seems I would need to access the port from the PC to get the driver? which would be impossible given that I won't have a functional network connection. Though, I could in any case just download the driver straight up from Realtek's website and put that into the installer image.

Again, some guidance about the proper way to proceed in this case would be appreciate it.

Thanks in advance.

*As an aside*: I understand that maybe in production systems it is more common to use Intel NICs. But there are quite a few models of motherboards from the big players (MSI, Gigabyte, ASRock, and so on) that come with this Realtek 2.5Gbps NIC. I think FreeBSD would make a BIG favor to not a small number of home users were it to include this driver in the base system.


----------



## T-Daemon (Apr 8, 2021)

JMOR said:


> By the way, I think this is the driver I should be using: realtek-re-kmod (Kernel driver for Realtek PCIe Ethernet Controllers from FreshPorts). But, it seems I would need to access the port from the PC to get the driver? which would be impossible given that I won't have a functional network connection. Though, I could in any case just download the driver straight up from Realtek's website and put that into the installer image.


Better download the FreeBSD package than the driver from the manufacturer:

`fetch https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/All/realtek-re-kmod-v196.04_2.txz`

After the system is installed drop into a shell of the installer (or reboot into the new system) and extract (tar(1)) the package into the new system, edit /boot/loader.conf, set the necessary variables to load the driver.

Manually extracting the package won't be registered in the systems local package database. To make the database aware of the package reinstall the package with the systems ports(7) / pkg(8) facilities.

There are +COMPACT_MANIFEST and +MANIFEST files leftovers from the package after extracting manually, you might want them removed.


----------



## SirDice (Apr 8, 2021)

If you're downloading packages in advance might as well download the package for pkg too. Extract it and use the included `pkg-static` command to install itself. Then use pkg-add(8) to install the downloaded module.


----------



## T-Daemon (Apr 8, 2021)

SirDice said:


> If you're downloading packages in advance might as well download the package for pkg too. Extract it and use the included `pkg-static` command to install itself. Then use pkg-add(8) to install the downloaded module.


Nice!

Assuming downloaded packages are in  /tmp :

```
tar xf pkg-1.16.3.txz
usr/local/sbin/pkg-static add pkg.1.16.3.txz
pkg add realtek-re-kmod-v196.4_2.txz
rm -r usr +COMPACT_MANIFEST +MANIFEST pkg-1.16.3.txz realtek-re-kmod-v196.4_2.txz
```


----------



## SirDice (Apr 8, 2021)

Fixed the code for you, /usr/local/sbin/pkg-static should be relative from the directory you extracted the .txz in, so it's usr/local/sbin/pkg-static. Then it doesn't matter where you saved or extracted the archive (I usually just do this in /tmp).


----------



## andmars (Jun 15, 2021)

Hi, I'm in the same boat here. I was able to do a netinstall freebsd on my laptop but not on my main PC, due to the RTL8125B on my ASUS TUF GAMING B550 main board.

So now I'm trying to wrap my head around what I need to do here before the installation. Since netinstall won't work I downloaded and dd the disc1.iso to my usb stick (don't have any optical drives).
That way I can boot up my machine into freebsd and install it.
Then what? Don't understand how to get the files "pkg" and "realtek-re-kmod" (have them downloaded to my current arch linux) over to the newly installed freebsd and into /tmp? Will I need an extra usb drive, mount it and move the files over?
Or is there a way to prepare the install media before installing?
What am I missing here?


----------



## Vull (Jun 16, 2021)

andmars said:


> Hi, I'm in the same boat here. I was able to do a netinstall freebsd on my laptop but not on my main PC, due to the RTL8125B on my ASUS TUF GAMING B550 main board.
> 
> So now I'm trying to wrap my head around what I need to do here before the installation. Since netinstall won't work I downloaded and dd the disc1.iso to my usb stick (don't have any optical drives).
> That way I can boot up my machine into freebsd and install it.
> ...


I can maybe get you part way there, although I haven't done this either. Since you don't have a working FreeBSD system yet, you will probably need an extra USB drive for the two extra files.

You probably won't be able to use FreeBSD's `fetch` command either, but you can copy and paste the URL, without the fetch keyword, into your web browser's address widget, and it should offer you a chance to download the file on your Linux drive:

`https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/All/realtek-re-kmod-v196.04_2.txz`

I'm unable to determine the exact location of the pkg-1.16.3.txz file, but maybe someone else can help you with that. The version number may have changed, since this thread is already over a couple of months old.

Once you have the two files, you should be able to copy them onto a scratch USB drive which is formatted with vfat32 or whatever, using your Arch Linux system. Then when you run the FreeBSD installer, or after you reboot, you can get to a root shell, find your second USB drive with `ls /dev/da*`, and mount the drive with something like `mount -t msdosfs /dev/da0s1 /mnt`. Copy the files into /tmp, then refer back to post #4 above, and take it from there.

Edited to add: I missed the point where you already have FreeBSD on your laptop. Since you already have a FreeBSD box, you can generate pkg-1.16.3.txz yourself using the command `pkg create -x pkg` which will create the file in your present working directory.


----------



## T-Daemon (Jun 16, 2021)

Vull said:


> I'm unable to determine the exact location of the pkg-1.16.3.txz file,


How so? It's right there  :



			https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/All/pkg-1.16.3.txz
		




Vull said:


> Since you already have a FreeBSD box, you can generate pkg-1.16.3.txz yourself using the command `pkg create -x pkg` which will create the file in your present working directory.


That would work if ports-mgmt/pkg was installed, but it looks like andmars hasn't it installed. What remains is to install it as described earlier.


----------



## T-Daemon (Jun 16, 2021)

andmars said:


> Or is there a way to prepare the install media before installing?


There are ways to prepare the FreeBSD installer media, but other methods than to use a spare USB drive, as Vull suggested, would take longer to bring the files over to FreeBSD.


----------



## Vull (Jun 16, 2021)

T-Daemon said:


> How so? It's right there  :
> 
> 
> 
> ...



Ha like the nose on my face I didn't see it. Also, after re-reading his first paragraph, I saw where I overlooked the fact that he has two FreeBSD boxes, one with "netinstall" FreeBSD, and one without, so he should be able to generate pkg-1.16.3.txz on his laptop after running `pkg bootstrap` or `pkg install ...` on it.


----------



## andmars (Jun 17, 2021)

Hi there, it worked just fine. All I had to do afterward, was add


```
ifconfig_re0="DHCP"
ifconfig_re0_ipv6="inet6 accept_rtadv"
```

and I had working internet. In fact I'm writing this on my main PC on FreeBSD 13 right now.

Unfortunately I'm not that happy with it, yet. Lots of tiny things that don't quite work as smootly as in my 12 years with Arch Linux. I will tinker with it during the weekend but I'm affraid I might go back to linux even though I don't like the big corporate influence on it, the systemd stuff, etc. We'll see. Thanks for your help, tough!


----------



## Vull (Jun 17, 2021)

Good luck & have fun!


----------



## fundon (Aug 29, 2021)

I use iperf3 to test it. Just It just has 1000MB. The card cant switch to media 2500Base-T mediaopt full-duplex.

ifconfig_re0="inet 192.168.0.30 netmask 255.255.255.0 media 2500Base-T mediaopt full-duplex"

Server listening on 5201 (test #1)
-----------------------------------------------------------
Accepted connection from 192.168.0.13, port 51340
[  5] local 192.168.0.30 port 5201 connected to 192.168.0.13 port 51341
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec   111 MBytes   934 Mbits/sec
[  5]   1.00-2.00   sec   111 MBytes   935 Mbits/sec
[  5]   2.00-3.00   sec   111 MBytes   935 Mbits/sec
[  5]   3.00-4.00   sec   111 MBytes   935 Mbits/sec
[  5]   4.00-5.00   sec   111 MBytes   935 Mbits/sec
[  5]   5.00-6.00   sec   111 MBytes   935 Mbits/sec
[  5]   6.00-7.00   sec   111 MBytes   935 Mbits/sec
[  5]   7.00-8.00   sec   111 MBytes   935 Mbits/sec
[  5]   8.00-9.00   sec   111 MBytes   934 Mbits/sec
[  5]   9.00-10.00  sec   111 MBytes   935 Mbits/sec
[  5]  10.00-10.00  sec   215 KBytes   940 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-10.00  sec  1.09 GBytes   934 Mbits/sec                  receiver
-----------------------------------------------------------
Server listening on 5201 (test #2)
-----------------------------------------------------------


----------



## r2com (Jun 17, 2022)

I have same chipset for ethernet, guys, i cannot get this file:


			https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/All/realtek-re-kmod-v196.04_2.txz
		


it says file not found, and manually navigating to /All/... says "forbidden", please help where to get this file?

Also, where to get this:
pkg-1.16.3.txz


----------



## T-Daemon (Jun 17, 2022)

r2com said:


> I have same chipset for ethernet, guys, i cannot get this file:
> https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/All/realtek-re-kmod-v196.04_2.txz


That file is long gone. FreeBSD packages are build continuously, software version numbers change, package container suffixes have been changed as well, now *.pkg is used.

You can get the file now from this address: https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/All/realtek-re-kmod-196.04.pkg

Alternatively, if you have a mobile data plan, you can install with pkg-install(8) directly. Plug in a mobile phone, activate USB tethering, run on the FreeBSD system `dhclient ue0` and follow the instructions viewed in the package post-install message.



r2com said:


> Also, where to get this:
> pkg-1.16.3.txz





			https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/All/pkg-1.17.5_1.pkg


----------



## r2com (Jun 17, 2022)

actually I got the files now by looking at version and guessing and modifying link and it downloaded both files.

I will just add few other steps (aside from the ones proposed for installing pkg & driver) I did (just for own reference and reference of others later looking at post; also tell me if what I did later is not best):

1) Add these to /boot/loader.conf

```
if_re_load="YES"
if_re_name="/boot/modules/if_re.ko"
```

2) Modify /etc/rc.conf and add this:

```
ifconfig_re0="DHCP"
```

3) run this: /etc/netstart

4) reboot

Now I do see Ethernet working, so its done I assume? (btw dont have 2.5Gbps router/connection yet, but ethernet works as of now and I can update pkg)


----------



## andmars (Jul 13, 2022)

So, here we are about one year later and I'm givin FreeBSD another shot.
Though this method worked last year, it doesn't work now.
I did a fresh memstick install of 13.1. and after reboot I mounted the usb drive with pkg and the realtek driver and copied it to /tmp. But the next step doesn't work anymore;

```
usr/local/sbin/pkg-static add pkg.1.18.3.pkg
```
/usr/local/sbin/ doesn't seem to exist on my system so I couldn't add pkg.
What am I missing here?

EDIT: Okay, I'm an idiot. I scipped the tar xv part because I thought: Hey, why would I need it when it's already in .pkg format?!


----------



## SirDice (Jul 13, 2022)

Yeah, it's a bit of a chicken and egg conundrum, because you need pkg(8) to install pkg(8). Luckily the package comes with a usable pkg-static(8), but you'll need to extract that first.


----------



## diizzy (Jul 13, 2022)

You can use pkgs.org to easily extract URLs 

For example:





						Search Results for realtek-re-kmod
					

Search Results for realtek-re-kmod




					pkgs.org
				





			https://freebsd.pkgs.org/13/freebsd-amd64/pkg-1.18.3.pkg.html


----------



## _martin (Oct 25, 2022)

Installing it through pkg is a way to go. But sometimes you may be in the situation you just want that module loaded and take care of the "paperwork" later. You can extract the contents of pkg, copy the module, reboot it and fix later over network. 
	
	



```
h3o:(/a)# tar xf realtek-re-kmod-197.00~201db56b93.pkg
h3o:(/a)# cp boot/modules/if_re.ko /boot/kernel/
```
Edit /boot/loader.conf

```
if_re_load="YES"
if_re_name="/boot/modules/if_re.ko"
```
Adjust rc.conf as you need (static IP or DHCP). Once booted and on network you can install the package via pkg to make it by the book.


----------



## SleepWalker (Dec 23, 2022)

Has anyone tested the new driver version 197.00? 

I am trying to get it to work on aarch64 Rockchip RK3568 - NanoPi-R5S.
I have three Ethernet ports, two of them RTL8125BG.

Does anyone have experience testing exactly RTL8125BG? 
I see a link up at 2.5GbE, but no packets get through.


----------

