Adding network Realtek support in FreeBsd (OPNSense)

In my case, I have installed FreeBSD 13 (OPNSense 22.1), on motherboard with single NIC 2.5Gb/s (Realtek RTL8125). Unfortunately by default OPNSense not provide out-of-box drivers for ‘recent’ multi-gigs Realtek NIC. So, basically host haven’t a network / internet access.

(Note: an alternative solution is to add another ‘basic/old’ NIC or sharing phone connection)
(Context remark: I will not use Realtek NIC as main NIC, when I would have bought Intel PCIe NIC)

First check

Freebsd supported hardware is listed here : https://www.freebsd.org/releases/13.0R/hardware/

First verify your NIC isn’t present here
ifconfig -a

Next search your network card (it should be prefixed with none: if driver is missing )
pciconf -vl

Resolution

We need to add official (proprietary) Realtek drivers.

Find version package here : https://www.freshports.org/net/realtek-re-kmod/
Example download link for 196.04 version : https://pkg.freebsd.org/FreeBSD:13:amd64/latest/All/realtek-re-kmod-196.04.txz

Assuming your host haven’t any network access, download file from another computer and put it into an USB key. (Otherwise simply install package realtek-re-kmod)

# mount usb (in my case it was da0 device, first partition p1 = da0p1)
mkdir /mnt/usbstick
ls -l /dev/da0*
mount -t msdosfs /dev/da0p1 /mnt/usbstick

pkg add /mnt/usbstick/realtek-re-kmod-v196.04.txz

# usb unmount
umount /mnt/usbstick
rm -rf /mnt/usbstick

Edit /boot/loader.conf (freebsd), or /boot/loader.conf.local (OPNSense), add following lines :

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

Verify changes

Then reboot and verify :

reboot
# ensure if_re.ko  is loaded
kldstat
# verify if your NIC is present here
ifconfig -a

For OPNSense, now you can choose option 1) Assign interfaces from opnsense main menu, assign your NIC and access OPNSense Web-gui.

Conclusion

Yes, ‘some’ ‘recent’ NIC aren’t supported out-of-box (especially other than Intel NIC), fortunately this can (most of time) be fixed manually.
I recommend you checking supported hardware list, before choosing your NIC.

I share here my step by step method to fix this, I hope it will help you / speed up resolution.

Share with

Twitter Facebook Email
Written on June 3, 2022

Tags : OPNSense