Installing OPNsense on the PN42: Fixing the RTL8125B LAN Driver

Installing OPNsense on the PN42: Fixing the RTL8125B LAN Driver

This article is also available in other languages.

I bought an ASUS PN42 to use as a new router and tried to install OPNsense on it, but I got stuck right at the start. The built-in Realtek RTL8125B LAN ports didn’t show up as interfaces at all.

OPNsense is based on FreeBSD, and its default Realtek driver couldn’t recognize this chip. With no working LAN port I couldn’t get through the installer, and with no internet connection I couldn’t download a driver either. Here’s how I got past it.


Installing over a temporary network

Since the built-in LAN ports were unusable, I first needed another network device that FreeBSD recognizes out of the box.

If you have a spare USB LAN adapter, plug that in. If not, connect a smartphone with a USB cable and turn on USB tethering. Fortunately, smartphone tethering is detected without any extra driver.

Assign this temporary network as the WAN interface and the installer completes normally, and the internet connection stays up after installation. You only need to download one driver package, so speed hardly matters.


Installing the Realtek driver

After installation, open the shell from option 8 (Shell) in the OPNsense console menu. Then install the realtek-re-kmod package from FreeBSD ports. It packages Realtek’s official driver as a kernel module.

pkg install realtek-re-kmod

When the installation finishes, you’ll see a message like this.

[1/1] Fetching realtek-re-kmod-1101.00.1403000.pkg: 100%  157 KiB
Checking integrity... (0 conflicting)
[1/1] Installing realtek-re-kmod-1101.00.1403000...
[1/1] Extracting realtek-re-kmod-1101.00.1403000: 100%
=====
Message from realtek-re-kmod-1101.00.1403000:

--
Add the following lines to your /boot/loader.conf
to override the built-in FreeBSD re(4) driver.

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

By default, the size of allocated mbufs is enough
to receive the largest Ethernet frame supported
by the card.    If your memory is highly fragmented,
trying to allocate contiguous pages (more than
4096 bytes) may result in driver hangs.
For this reason the value is tunable at boot time.
e.g. - if you don't need Jumbo frames you can lower
the memory requirements and avoid this issue with:

hw.re.max_rx_mbuf_sz="2048"

To enable Wake on LAN (WoL) support you might need
to set the following tunables:

hw.re.s5wol="1"
hw.re.s0_magic_packet="1"

If you experience network hangs with IPv6 enabled,
you might need to disable the checksum offloading
by adding the following parameters to the related
ifconfig line in your /etc/rc.conf file:

-rxcsum -txcsum -rxcsum6 -txcsum6

The important part is the beginning. Installing the package isn’t enough on its own: you also have to tell the system to load the kernel module you just installed instead of FreeBSD’s built-in re(4) driver at boot. The rest are optional tuning settings.

Setting Purpose
hw.re.max_rx_mbuf_sz="2048" Reduces memory use when you don’t need jumbo frames, preventing driver hangs
hw.re.s5wol, hw.re.s0_magic_packet Enables Wake on LAN (WoL)
-rxcsum -txcsum -rxcsum6 -txcsum6 Disables checksum offloading if the network hangs with IPv6

Loading the new driver at boot

The message says to add these lines to /boot/loader.conf, but on OPNsense that file can be overwritten during updates, so put them in /boot/loader.conf.local instead. Create the file and add the following.

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

hw.re.s5wol="1"
hw.re.s0_magic_packet="1"

The first two lines load the new driver, and the last two are settings I added to use WoL. If you don’t need WoL, the first two lines are enough.

Save the file and reboot, and the RTL8125B LAN ports are detected properly. Now reassign the built-in LAN ports to WAN/LAN and unplug the temporary USB LAN adapter or smartphone, and you’re done.


Wrapping up

Here’s a quick summary of the steps.

  1. Assign smartphone USB tethering (or a temporary USB LAN adapter) as WAN and install OPNsense
  2. Install the driver from the console shell with pkg install realtek-re-kmod
  3. Add the driver loading settings to /boot/loader.conf.local and reboot

If you’re planning to run OPNsense on a mini PC with the same chipset, I recommend keeping a smartphone for tethering nearby from the start.

References

author profile
winetree94

Web frontend engineer. Bedroom DevOps engineer.
I'd love to blog consistently, but let's be real—I'm way too lazy for that.