Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
compile realtek network driver for pfsense 2.4.x

How to compile and install latest realtek network driver in pfSense 2.4.x (FreeBSD 11.1)

  1. Download FreeBSD 11.1 VMDK and create a VM with it as HDD.

  2. Get FreeBSD source tree for your exact FreeBSD version and uncompress it to /usr/src:

    fetch -o /tmp ftp://ftp.freebsd.org/pub/`uname -s`/releases/`uname -m`/`uname -r | cut -d'-' -f1,2`/src.txz
    tar -C / -xvf /tmp/src.txz
    
  3. Download latest Realtek network driver (you need to input an email address).

  4. Uncompress driver:

    tar xvzf 0007-rtl_bsd_drv_v194.01.tgz
    
  5. Make driver:

    cd rtl_bsd_drv_v194.01
    make
    
    1. If the last command fails, change the following line in file if_re.c

      From: #include <dev/re/if_rereg.h>

      To: #include "if_rereg.h"

  6. Copy the file if_re.ko to the /boot/kernel folder in pfSense device.

    scp if_re.ko root@<pfSense device IP>:/boot/kernel

  7. Change file permissions in if_re.ko file accessing through SSH to pfSense.

    chmod 555 /boot/kernel/if_re.ko

  8. Modify /boot/loader.conf.local file and add the following line at the end of the file: if_re_load="YES"

    • Through console: vi /boot/loader.conf.local
    • Through web: Diagnostics > Edit File and click Load. When finished editing click Save.
  9. Reboot pfSense.

  10. After restart, verify if module is installed through ssh with kldstat. Example execution:

    [2.4.2-RELEASE][root@pfSense.local]/root: kldstat
        Id Refs Address            Size     Name
         1    7 0xffffffff80200000 2c3ea98  kernel
         2    1 0xffffffff82e3f000 80900    if_re.ko
         3    1 0xffffffff83021000 46c6     cryptodev.ko
    

Based on:

@chennin
Copy link

chennin commented Jan 6, 2018

To: #include if_rereg.h"

Should be #include "if_rereg.h"

@WiggyWare
Copy link

WiggyWare commented Jan 16, 2018

Thank you very much for putting this together!

@nikolay-zhelev
Copy link

nikolay-zhelev commented Mar 19, 2018

Hi guys,

Thanks for this guide.

In my opinion the guide is a bit unclear of how to run the freeBSD on a virtual machine and how to mount the drivers on the virtual machine in order to compile them.
I spent hours trying to compile those drivers and I want to share my experience and hopefully save someone else's time:

If you use VMWare workstation please do the following:
Download the realtek drivers on you desktop. Install UltraISO software for example and create ISO image file containing "0007-rtl_bsd_drv_v194.01.tgz".
Follow this guide to create virtual machine for freebsd: Here
In the virtual machine settings Hardware/ CD/DVD and add the path of the image file you created with the realtek drivers.

Run the virtual machine. Login as root. Execute the following command in order to mount the drivers to the cdrom:
mount -t cd9660 /dev/cd0 /cdrom
Follow the guide above. Step 4 becomes: tar xvzf /cdrom/0007-rtl_bsd_drv_v194.01.tgz
If you face an error with make command edit the file using "VI" editor: vi if_re.c
In my case #include <dev/re/if_rereg.h> became #include <if_rereg.h>
To make any changes to the file use "i" for input and once you're done, press i again, then ":" and "w" to write the file and "q" to quit vi. Here is a guide how to use vi: How to use VI.

Transfer the file using the virtual machine. The command is scp if_re.ko root@yourip:/boot/kernel

Good luck.

Regards,
Nick

@jovimon
Copy link
Author

jovimon commented Apr 16, 2018

Thanks @chennin, typo corrected.

Thanks @nikolay-zhelev for your alternative guide. =)

@Hr46ph
Copy link

Hr46ph commented May 30, 2018

So if /boot/loader.conf.local doesn't exist, do I edit loader.conf or create the file and add that 1 line to it?

@cschneider005
Copy link

cschneider005 commented Jun 1, 2018

@jovimon the scp if_re.ko root@<pfsense ip>:/boot/kernel from nikolay's post should be included in original guide, without the :/boot/kernel part the command will go through without returning a code or copying any files. thank you for the guide though, it was extremely helpful!!

@Hr46ph you should run the vi /boot/loader.conf.local command whether the file exists or not. if it doesn't exist it will create a new file where you can add the if_re_load="YES" line.

@DRON4eg
Copy link

DRON4eg commented Aug 1, 2018

Thanks buddy, how did I suffer with a gigabit connection ... and the error "re0 watchdog timeout"

@tn00364361
Copy link

tn00364361 commented Oct 10, 2018

Is compiling with FreeBSD 11.2 needed for pfSense 2.4.4 and 2.4.5? Here it says that pfSense 2.4.4 and 2.4.5 is based on 11.2 instead of 11.1.

@mmasson
Copy link

mmasson commented Nov 15, 2018

W00t! Got it working again... When I went from 2.3.x to 2.4.x the re driver that was previously compiled stopped working.

BTW, the link to realtek doesn't seem to work anymore, I was able to find a shady replacement here:
https://blog.monogatari.pl/wp-content/uploads/2018/09/rtl_bsd_drv_v194.01.tar

It is attached to an article for the same problem, but with FreeNAS:
https://blog.monogatari.pl/en/2018/03/freenas-realtek-8111f-and-re0-watchdog-timeout-error-universal-solution/

Thanks!

@compuguy
Copy link

compuguy commented Dec 11, 2018

If you don't mind giving your email address to Realtek (or use a burner account) you can also get the drivers here @mmasson: https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software

@jovimon
Copy link
Author

jovimon commented Jan 4, 2019

@cschneider005 @compuguy thank you for the info, I updated the guide accordingly.
@Hr46ph as you've already been told, you need to create the file if it doesn't exist.
@tn00364361 I installed the driver in earlier FreeBSD 11.1 based versions and updated to 2.4.4-RELEASE-p1 (based on FreeBSD 11.2-RELEASE-p4) through the web interface and have detected no issues so far ...

@tangohosts
Copy link

tangohosts commented Jan 28, 2019

fetch -o /tmp ftp://ftp.freebsd.org/pub/`uname -s/releases/uname -m/uname -r | cut -d'-' -f1,2`/src.txz
tar -C / -xvf /tmp/src.txz this is jargen to me, can someone provide an example of what I'd need to type to download http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/11.2-RELEASE/

@jddonovan
Copy link

jddonovan commented Mar 7, 2019

Thanks for the easy-to-follow guide!

It's been generally recommended to disable checksum offloading with FreeBSD built-in realtek drivers. Any experiences with checksum offloading with these compiled drivers? Any need to disable it?

@zphelj
Copy link

zphelj commented Mar 14, 2019

Outstanding guide, thank you! Note: I built using release 11.2, working fine.

@fkoczan
Copy link

fkoczan commented Mar 15, 2019

I have made FreeBSD 12 package.
https://drive.google.com/file/d/1Ch4Z_w7gpbrpavQ4KhPUXUzYhRyzqnye/view?usp=sharing
I dont consider it my work - I have just packed it in one archive. It is stable for me on 12.0 p3 more than
"sed -i -e 's/TAILQ_FOREACH/CK_STAILQ_FOREACH/g' if_re.c"

@cuiwm
Copy link

cuiwm commented Nov 30, 2019

Thanks for the outstanding guide, it works on FreeBSD 11.2-RELEASE-p10 with 2.4.4-RELEASE. The error (watchdog timeout) gone.

@fromage9747
Copy link

fromage9747 commented Mar 15, 2020

@tangohosts
fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/11.2-RELEASE/src.txz

@cooljimy84
Copy link

cooljimy84 commented May 19, 2020

Thank you !

@ygaeon
Copy link

ygaeon commented Sep 29, 2020

About 1 month ago I ditched my XCP-ng installation of pfSense in favor of bare metal installation. Since then I've had weird disconnects (seemingly when I load the connection a bit ~>300Mbit/s) and Gateway alarms going of, causing the gateway to be brought DOWN and UP again. Also saw a lot of pfSense kernel: arpresolve: can't allocate llinfo for <IP> on <iface> messages.

I saw messages floating around about FreeBSD and Realtek, but I didn't have a solution to it, until this guide. Thanks!

I've made a few additions to the guide as I discovered some issues:

  • I downloaded the qcow2 version from here: https://download.freebsd.org/ftp/releases/VM-IMAGES/11.3-RELEASE/amd64/Latest/
  • Extracting the src.txz filled the volume and I couldn't continue and had to resize the volume first:
    • $ qemu-img resize FreeBSD-11.3-RELEASE-amd64.qcow2 +3G
    • Boot up the image. (eg. $ qemu-system-x86_64 -m 4096 -enable-kvm -drive file=FreeBSD-11.3-RELEASE-amd64.qcow2,format=qcow2 -cpu host -smp cores=4 -usb -device usb-tablet)
    • # gpart show ada0 will say that the volume is [CORRUPT] but a simple # gpart recover ada0 will solve that.
    • Check what partition "freebsd-ufs" is on and if you're lucky, it's the last partition and you won't have to remove swap first.
    • # gpart resize -i <partition id> -s 6G -a 4k ada0
    • # growfs /dev/ada0p<partition id> will probably fail on you "Operation not permitted" but I found that I could use # service growfs onestart successfully instead.

Hope this helps the next guy :-)

PS! I'm on ~30 minutes stable connection now, where it would die on me every 5 minutes before this. Fingers crossed!

@jddonovan
Copy link

jddonovan commented Apr 12, 2021

This guide still works for pfsense 2.5.x. Note that I used Freebsd 12 to build the latest driver available from Realtek.

I didn't try dropping in the previous version built with Freebsd 11. No idea if that would work (when e.g. upgrading from pfsense 2.4.x to 2.5.x).

@riprip74
Copy link

riprip74 commented May 18, 2021

Thanks for the guide.
I did it on pfsense 2.5.1-RELEASE (amd64)built on Mon Apr 12 07:50:14 EDT 2021FreeBSD 12.2-STABLE
Of course, I used a freebsd 12.2 VM and 12.2 source files.
I edited the /boot/loader.conf instead of /boot/loader.conf.local which doesn't exist.
Everything is up and running with the new driver!

@jddonovan
Copy link

jddonovan commented Sep 5, 2021

Just as a FYI, the driver is available as a pfsense package. Look for realtek-re-kmod. Might be behind Realtek source or freebsd-freshports though. Current pfsense package version is realtek-re-kmod-v196.04_2, freshports version is _3.

@jovimon
Copy link
Author

jovimon commented Sep 6, 2021

Hello @jddonovan, thank you very much for your find!
I have not tested it, but for everyone else, you have to enter the shell (through SSH or Diagnostics > Command Prompt) and issue this command: pgk search realtek-re-kmod.
Then, issue this command pkg install realtek-re-kmod-<version> with the version number returned in the previous command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment