How To Enable Wireguard on FreeNAS 11.3

WireGuard is quickly gaining popularity in the VPN marketplace due to its speed, simplicity, and modern cryptography standards. Starting with FreeNAS version 11.3-RC1, it is possible to connect your NAS directly to a WireGuard network with a few easy steps.

We get started on this by creating some custom tunables to enable the WireGuard service and give it a default interface. To do this you must first navigate to System -> Tunables -> Add.

Enable the WireGuard service by adding “wireguard_enable” -> “YES” in rc.conf.

Next, create another tunable and add “wireguard_interfaces” -> “wg0” in rc.conf.

When finished, you should have the following two variables set and enabled.

Next, we will need to create a post-init script that will place the WireGuard config into the correct location at startup. Navigate to Tasks -> Init/Shutdown Scripts -> Add.

Create the following command and set it to run at post-init:

“mkdir /usr/local/etc/wireguard && cp /root/wg0.conf /usr/local/etc/wireguard/wg0.conf && /usr/local/etc/rc.d/wireguard start”

You can configure the /root/wg0.conf file and apply a WireGuard configuration to attach to whatever WireGuard network you define. It can be a single point-to-point to anything running WG, or even with full routing. Example use cases are:

  • Access data on a NAS from your Remote Laptop
  • Linking NAS to NAS for replication
  • Attaching a managed NAS to a remote network
  • Access to your NAS from your smartphone

We need to create the /root/wg0.conf which will contain the specific WireGuard configuration to apply at boot. This configuration is beyond the scope of this article, but there are quickstart guides and tutorials available online as well as the built-in ‘wg-quick’manpage.

Once you have a valid /root/wg0.conf, rebooting the system should bring up the WireGuard interface, and you’ll see a ‘wg0’ device in the output of ‘ifconfig’.

Congratulations, you have successfully linked your FreeNAS system to a secure WireGuard tunnel!

6 Comments

  1. Isaiah Ritter

    I have followed this guide exactly as described. However, when starting WG, I keep getting the following report. I do not understand why iptables command is not found.

    [#] wireguard-go wg0
    INFO: (wg0) 2020/02/09 17:02:47 Starting wireguard-go version 0.0.20190908
    [#] wg setconf wg0 /tmp/tmp.6DEHwN79/sh-np.yZM9jB
    [#] ifconfig wg0 inet 10.100.100.1/24 10.100.100.1 alias
    [#] ifconfig wg0 mtu 1420
    [#] ifconfig wg0 up
    [#] route -q -n add -inet 10.100.100.2/32 -interface wg0
    [+] Backgrounding route monitor
    [#] iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    /usr/local/bin/wg-quick: line 379: iptables: command not found
    [#] rm -f /var/run/wireguard/wg0.sock

    Reply
    • Joon Lee

      Isaiah,

      iptables is for Linux. FreeNAS is a FreeBSD based system so that command won’t work.

      Reply
  2. Brian

    Will these changes in 11.3 allow similar procedures work for ZeroTier instead of Wireguard?

    Reply
    • Joon Lee

      Unfortunately, no. This is a tutorial on how to set up Wireguard, not ZeroTier.

      Please try posting your question on the forums! http://www.ixsystems.com/community

      Reply
  3. Andrew Alles

    Anyone have any luck with DNS resolution over the tunnel with these instructions for a DNS server hosted on a different subnet? Point-to-point traffic works fine across the tunnel; I’ve already got IP forwarding on, so I’m wondering if there’s some NAT stuff I have to do in addition to that.

    Reply

Submit a Comment

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

ESG Labs: TrueNAS Technical Report

iXsystems values privacy for all visitors. Learn more about how we use cookies and how you can control them by reading our Privacy Policy.