FreeNAS and Realtek RTL8168C/RTL8111DP/RTL8111E network card

Quick links to compiled v1.80 drivers
Ethernet Driver for Intel
Ethernet Driver for AMD64 (Thanks to Ruslan)

As I mentioned in a previous post, I built myself a NAS based on FreeNAS. It’s been rock solid for about 3 weeks now, no hiccups. One initial issue I did have was getting the RTL8168C/RTL8111DP/RTL8111E network card chipset to work. There is no FreeNAS out of the box support for this chipset, so I had to compile my own from source found on the Realtek website which you can find here. If you have issues downloading or compiling it, I’ve compiled version 1.80 which you can download from the top of this page. Ruslan has kindly compiled an AMD64 version as well.

First and foremost, verify that the module actually works and you can bring up your network card and get some activity over it. I’m going to assume at this point that you have no way of copying something onto your FreeNAS other than USB, so copy if_re.ko to a USB stick and plug it into your NAS.

To mount the USB device, let’s first create a mount point.

# mkdir /mnt/usb

Now we need to find the USB device you just plugged in.

# dmesg
umass1: <USB 2 Flash Disk, class 0/0, rev 2.00/0.00, addr 3> on uhub4
da1 at umass-sim1 bus 1 target 0 lun 0
da1: <USB 2.0 Flash Disk 2.20> Removable Direct Access SCSI-2 device 
da1: 40.000MB/s transfers
da1: 119MB (244480 512 byte sectors: 64H 32S/T 119C)

What we’re looking for here is the da1

# mount_msdosfs /dev/da1 /mnt/usb

Now let’s see if we can load the module.

# kldload /mnt/usb/if_re.ko

If you don’t get any errors, you should see the module loaded.

# kldstat
Id Refs Address    Size     Name
 1   12 0x80400000 b134e4   kernel
 2    1 0x80f14000 195b4    if_re.ko
 3    1 0x8c32e000 e350     isboot.ko
 4    1 0x8c33d000 6a4f0    acpi.ko
 5    1 0x92284000 123000   zfs.ko
 6    1 0x923a7000 3000     opensolaris.ko
 7    1 0x92843000 4000     geom_nop.ko
 8    1 0x938cf000 9000     aio.ko
 9    1 0xa8768000 13000    geom_vinum.ko

So far so good, now bring up the interface and see if you can assign an IP address to it and ping another node on your network.
Sweet, all good, all we need to do now is copy the module to a location that isn’t going to get overwritten at boot, and edit loader.conf.

/cf is the filesystem where we will copy the module to, but it’s mounted as read only on boot, so let’s remount it as read/write.

# df /cf
Filesystem 1K-blocks  Used Avail Capacity  Mounted on
/dev/da0a      71062 64438  6624    91%    /cf

Substitue /dev/da0a to match your install.

# umount /cf
# mount -o rw /dev/da0a /cf

Copy if_re.ko from the USB to /cf/boot/kernel

# cp /mnt/usb/if_re.ko /cf/boot/kernel

Edit /cf/boot/loader.conf and add the following line.


That should be it, you can now unmount the USB stick which you used to copy the module and reboot. If all goes well, your network card should come up on boot. If you do have any issues with this, please post to the comments.

58 thoughts on “FreeNAS and Realtek RTL8168C/RTL8111DP/RTL8111E network card

  1. Have you investigated wake up on lan for this nic?

    # ifconfig re0 list caps
    ifconfig: unable to get driver capabilities

    # ifconfig re0 wol
    ifconfig: wol: Invalid argument

    Any ideas welcome

  2. Pingback: DIY RAID NAS 1 « Koeienjam

    • Hi Leo,

      Apologies for the late reply, but I still haven’t had a chance to test Wake On LAN. I probably wont get a chance to test it till the Christmas break either. Too busy with work and other stuff.

      Will let you know as soon as I do though.

  3. Thanks for these instructions,

    however, I cant get it to work

    when i run kldload it says
    unsupported file layout
    unsupported file layout
    kldload: can’t load /mnt/usb/rtl/if_re.ko: Exec Format error

    I am using the amd64 version of freenas. Is this why?

  4. Pingback: Mounting external USB NTFS drive to FreeNAS

  5. I’m a novice to both linux and FreeNAS so please be patient and explicit.

    I’ve assembled a FreeNAS box using the Gigabit Intel Atom board (GA-D525TUD) and thus have a Realtek RTL8111E NIC.

    I’m using a FreeNAS image on an internally mounted USB flashdrive.

    I’ve downloaded your compiled driver version 1.80 from above and have it on a usb drive.

    FreeNAS boots fine, I exit to Shell and execute your first two commands, mkdir and dmesg. The dmesg command results in a page of info, but ultimately ends with the da1 info you describe above and it corresponds to the usb drive.

    The problem is with the next command:
    # mount_msdosfs /dev/da1 /mnt/usb

    This returns an error message:
    mount_msdosfs /dev/da1: : Invalid arguement

    Is this related to the fact that I’m using another usb drive for the FreeNAS boot?


    • Hi Monte,

      Using the mount_msdosfs command assumes that the USB drive is formatted with the FAT32 filesystem. It’s pretty common to have FAT32 formatted USB drives when coming over from a Windows environment, but if you’re using some like NTFS, you can follow a later post of mine about mounting NTFS drives.

      Another thing, if your USB drive is partitioned in any way, then you need to tell it which partition you want to mount. I guess an easy way to do this is:

      * Plug the USB key in.
      * Run the following command: # ls -l /dev/da1*
      * See if it outputs anything other than /dev/da1 and try and mount that instead.

      Let me know how you go.

  6. Hi!!
    i have a problem with the loading of the if_re.ko. i use a old lan card to copy if_re.ko the local disk on NAS.

    nas:/# kldload /mnt/oiikj/
    Backup steam/ Movies/ if_re.ko* torrents/
    Knjige/ fuppes.db mp3/
    nas:/# kldload /mnt/oiikj/if_re.ko
    nas:/# kldstat
    Id Refs Address Size Name
    1 6 0x80400000 b134e4 kernel
    2 1 0x80f14000 6a4f0 acpi.ko
    3 1 0x83561000 123000 zfs.ko
    4 1 0x83684000 3000 opensolaris.ko
    5 1 0x8377d000 19000 if_re.ko

    I editeed the loader.conf and add just if_re_load=”YES”


    But on next reboot

    nas:~# kldstat
    Id Refs Address Size Name
    1 6 0x80400000 b134e4 kernel
    2 1 0x80f14000 6a4f0 acpi.ko
    3 1 0x83519000 123000 zfs.ko
    4 1 0x8363f000 3000 opensolaris.ko

    • Hi Boris,

      Apologies for the late reply.
      Are you copying the module to a location on the disk that doesn’t get overwritten on boot? /mnt/oiikj won’t exist when you reboot FreeNAS.

      Try moving it to the location that I suggested in the post (/cf) and see how you go.

  7. thanks for the great howto – I’d have been stuck with
    no ‘N’ in my NAS without your help.

    One slight tweak that might be useful to others:

    mount_msdosfs /dev/da1 /mnt/usb

    failed for me but

    mount_msdosfs /dev/da1s1 /mnt/usb

    worked instead.

  8. Hi Kristijan;

    Thanks a lot!! It works perfect.

    I was very excited with my new mainboard until I discovered the lan problem. Thanks to you, Iยดm even more excited now ๐Ÿ˜€ The next step: turn my nas into 64 bits

    I hope the 64 bit driver by Ruslan (thanks too :)) works, at least, as good as yours.


  9. Hey guys,

    Doing the exact same thing. Gigabyte Mobo, 64 bit. Have the module loaded, and it now even loads on boot. But there is no em0 interface ๐Ÿ™ All I get is lo0 and I cannot access my box via the net :SS

    any ideas?

  10. Hey Guys,

    I have had success in all of the steps until where I have to copy the if_re.ko file to a location which would be safe from overwrites. heres where it went wrong:

    # df /cf
    Filesystem 1K-blocks Used Avail Capacity Mounted on
    /dev/da0s1 2028552 71660 1956892 4% /cf

    # mount -o rw /dev/da0s1 /cf
    mount: /dev/da0s1 : Operation not permitted

    I’m at a loss and I’ve been working on this for weeks, so does anyone have an idea? I’m running a USB drive with the freeNAS liveCD, and I created with usb with unetbootin if that makes a difference.


    • Hi Joel,

      I’m going to state a few obvious things here, as I can’t be certain from your output on what you’ve tried.

      Do the following, and let me know at which point you get errors and paste them here:

      $ su –
      # df /cf
      # umount /cf
      # mount -o rw /dev/da0s1 /cf

      • Hi Kristijan,

        Thanks for replying so quickly. I only have an error upon the last command you mentioned, here is the exact response I get:

        # mount -o rw /dev/da0s1 /cf
        GEOM_LABEL: Label msdosfs/FREENAS removed.
        GEOM_LABEL: Label for provider da0s1 is msdosfs/FREENAS
        mount: /dev/da0s1 : Invalid argument

        I’m in way over my head here, so I apologize if this is a rudimentary question.


        • Hi Joel,

          Hmm, I haven’t encountered this problem before, so I’m not quite sure. What happens if you don’t specify the device and let it read out of /etc/fstab

          # mount -o rw /cf

          Failing that, I’d go ask in the FreeNAS forums, as they would have a better clue. Just out of curiosity, what version of FreeNAS are you running?


          • Hey Kristijan,

            I’m using version i386 live CD. I know its not the most recent stable build, but I’ve had trouble making anything else work properly.

            Here’s what I got:

            # mount -o rw /cf
            mount: Using “-t msdosfs”, since “-tmsods” is deprecated
            GEOM_LABEL: Label msdos/FREENAS removed.
            g_vfs_done():da0s1[WRITE(offset=136912, length=4096)]error = 1

            the last line keeps repeating every ~20 seconds

            Thanks so much for your help, I am going to post this issue on the freeNAS forums and see what’s up.


          • Hey Kristijan,

            It turns out my problem was that I created my LiveUSB on Windows with unetbootin, which installed its own bootloader. I extracted a freeNAS.img file to usb from freeBSD, and then I was able to copy if_re.ko to /cf/boot/kernel. It was there upon reboot, so it worked!

            Now, my only issue is that when I try to save changes to loader.conf to make the driver boot with the system it wont let me because loader.conf is read-only. Do you have a solution for this?

            Thanks again,

  11. Hey guys ,

    first sorry for my english but i’m a newbies french :p

    i had the same problem with the last version (7.2)

    you don’t have to mount /umount

    juste cp if_re.ko in /boot/kernel (and not /cf/boot/kernel) and add if_re_load=”YES” to /boot/loader.conf ๐Ÿ™‚

    i hope this will work for you as it was working for me ๐Ÿ™‚

    see ya

  12. Hi,

    Have you tried setting an MTU higher than 1500 (jumbo frames)? On my Linux server running on identical hardware I can set it as high as 7200 (but not 9000 unfortunately). With the 64bit driver from an earlier comment I only get the following:

    nas1:~# ifconfig re0 mtu 1501
    ifconfig: ioctl (set mtu): Invalid argument

    Does anyone know if there is a way to get around this limitation?

  13. RE: setting MTU 9000 (jumbo frames) with realtek 64bit driver

    I don’t think there is a way to do this, it looks like the realtek driver is just badly written and it is currently impossible to set the mtu over 1500 when using it.

    I even looked at backporting the re(4) driver (which has suppot for the realtek 8111e..etc) from freebsd 7.4 (compiled as a separate module) and seems that is impossible too.

    I ended up moving to freenas 8.0 which has a far better realtek driver that can utilize mtu 9000 on 64 bit, greatly improved my read/write speeds. Just make sure to get the updated kernel from freenas after you install 8.0 final if you do.

    • How is that state of ZFS in 8.0 though? Last I checked it didn’t handle disk failures well at all.

      Also, have you done any performance testing to see how much is gained with the higher MTU? In other words, does it justify the pain of the upgrade.

      • I haven’t had any issues with zfs in 8.0, from what I have read freenas is completely zfs focused in 8.0. Did you have a link to anyone discussing drive failure + recovery issues in 8.0?

        Here is my 0.7.2 64-bit vs 8.0 final (with updated kernel) 64-bit speeds:

        write: 40MB/sec
        read: 50MB/sec

        write: 60MB/sec
        read: 70MB/sec

        I’m running an intel atom mini-atx setup with 7-drives in raidz2.

        Being able to set mtu 9000 for jumbo frames makes a pretty big difference in speed and lowers cpu usage (smaller number of packets to handle).

  14. I followed this guide, and I finally got my NIC half working. I have an RTL8111E, and i can see it pull the MAC from the NIC on boot, but then right after that, the lights on the ethernet port go out, and FreeNAS doesn’t see the interface. ifconfig doesn’t see anything but lo0.

    Someone please help?

    • Also, if i manually load the driver, it pulls up the MAC address, then says “re0: unknown device device_attach: re0 attach returned 6”


  15. I get this on FreenNAS 8.0 amd64:

    module_register_init: MOD_LOAD (pci/if_re, 0xffffffff805a2370, 0xffffffff81042420) error 22

    Any ideas ?

    I get very similar to what other folks are getting as well in dmesg:

    re0: port 0xe800-0xe8ff mem 0xdcfff000-0xdcffffff,0xdcff8000-0xdcffbfff irq 17 at device 0.0 on pci4
    re0: Using 1 MSI messages
    re0: Chip rev. 0x2c800000
    re0: MAC rev. 0x00000000
    re0: Unknown H/W revision: 0x2c800000
    device_attach: re0 attach returned 6

    • Hi Brandon,

      The pre-compiled drivers that are linked in this post were originally compiled on FreeBSD 7.2. FreeNAS 8.0 is now based on FreeBSD 8, so I’m not sure if they can be simply copied across.

      Have you tried compiling the source using a FreeBSD 8 server? It may produce better results.

  16. Brilliant. Was despairing about my E35M1-I, but found this post. Well written and easy to follow even for a newb like me. The response about problems mounting the usb because the stick might be partitioned was particularly helpful. Had to change one line in the loader.conf to accommodate the amd64 change which seemed to work.

    Thanks very much.

  17. I’m trying to install PFSense 2.0 Final and i have Realtek 8111E on my Asrock H61DEL (chose this board because of multiple PCI-E x1 ports for interfaces). I have 3 Intel PRO/1000 wich turn on fine. But the Realtek dosen’t want to work. i have tried everything. I use the 64bits edition. Please HELP me.


  18. Pingback: Raid Systeme

  19. Got me out of mischief with the missus this one after I upgraded our Freenas mobo from a slow but reliable VIA c7 board to Asus E35M1 and had no network connectivity….many thanks!!!

  20. Thanks very much Kristijan and Ruslan. I bought an Intel Atom BOXD525MW motherboard to run FreeNAS. My brother used the 510 with no complaints, and they share chipsets (but not onboard NICs) so I didn’t expect any issues. I was upset when I encountered this issue, even more so when I found message boards claiming the driver couldn’t be added without rebuilding the entire image.

    Your method worked for me without a hitch the very first time. Thank you.

  21. Hi Kristijan,

    I’ve done everything what you said, but unfortunately I haven’t any success to get my network on Freenas 7 (the latest stable release…
    after reboot when I type kldstat, I have:

    but my lan is still

    LAN -> lo0

    and when I try to assign interfaces (1)
    nothing happened, I don’t have any option to choose re0, just Auto-detection, and nothing detected. Something is very strange, because there’s no green light on my network card….

    I tried 8.0.4 version of NAS, and everything work perfect…but there’s no uPNP, bittorrent etc…

    Any idea?


  22. FreeNAS v7.2 has its advantages over v8, and I’m happy I found this site. BIG THANKS!!!

    It’s the first time I try FreeBSD and there were a few differences from what you wrote at the end:

    I had to type “cd ..” to get to the “real” root for some reason, and even tho the directory cf existed there, the KO files were not in it but in /boot/kernel. And I didn’t have to unmount/mount any directory. For editing the file I used the editor “vi”.

  23. Back to this old post ! Hello everyone. :/D

    I met the same problem with my network controller RTL8111G on MSI motherboard (J1800I). So, I compiled the drivers for FreeBSD 9.2 kernel (x64) and it worked on both last releases of FreeNAS and NAS4Free. There is always an acpi issue with msi, but the system runs !

    Here is the link of driver (x64),

Leave a Reply

Your email address will not be published. Required fields are marked *