• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • About
    • Stephen Foskett
      • My Publications
        • Urban Forms in Suburbia: The Rise of the Edge City
      • Storage Magazine Columns
      • Whitepapers
      • Multimedia
      • Speaking Engagements
    • Services
    • Disclosures
  • Categories
    • Apple
    • Ask a Pack Rat
    • Computer History
    • Deals
    • Enterprise storage
    • Events
    • Personal
    • Photography
    • Terabyte home
    • Virtual Storage
  • Guides
    • The iPhone Exchange ActiveSync Guide
      • The iPhone Exchange ActiveSync Troubleshooting Guide
    • The iPad Exchange ActiveSync Guide
      • iPad Exchange ActiveSync Troubleshooting Guide
    • Toolbox
      • Power Over Ethernet Calculator
      • EMC Symmetrix WWN Calculator
      • EMC Symmetrix TimeFinder DOS Batch File
    • Linux Logical Volume Manager Walkthrough
  • Calendar

Stephen Foskett, Pack Rat

Understanding the accumulation of data

You are here: Home / Everything / Terabyte home / How To Install ZeroTier on TrueNAS 12

How To Install ZeroTier on TrueNAS 12

February 3, 2022 By Stephen Leave a Comment

ZeroTier is an incredibly useful tool to enable true access from anywhere to any networked resource. I’ve been using it for a few months to access my Home Assistant instances, VNC to my home Mac, and log in to my servers even as I’m traveling and using odd networks like airplane and hotel Wi-Fi and LTE on my iPhone. Although TrueNAS has removed ZeroTier support, the FreeBSD package is easy to install and seems to work fine! The only issue is that it doesn’t persist across reboots without some major risky work.

Proof that ZeroTier can run natively on TrueNAS 12!

You would probably like my other article, How to Connect Everything from Everywhere with ZeroTier

FreeNAS, TrueNAS, and ZeroTier

TrueNAS is one of the best options for building a home or small office fileserver. Formerly known as FreeNAS, it uses ZFS and FreeBSD to provide reliable and flexible storage. I’ve previously written about my home TrueNAS build, which I use for general file storage as well as Time Machine backups, and it’s still going strong.

ZeroTier was offered as an installable package for FreeNAS but was removed in version 11.3. According to Kris Moore, SVP of Engineering at iXsystems, maker of TrueNAS, it was removed for licensing reasons. Apparently, ZeroTier no longer allows governmental or SaaS use, and iXsystems felt this was incompatible with TrueNAS. Although it is possible to access a TrueNAS system using OpenVPN, WireGuard, or even through a router on a ZeroTier network, I strongly prefer a native ZeroTier client.

Install FreeBSD Packages on TrueNAS 12

Since TrueNAS is built on FreeBSD 12, it can easily run the native FreeBSD build of ZeroTier. Although TrueNAS is configured by default not to allow installation of FreeBSD packages, it is fairly easy to enable this and install ZeroTier.

The first step is to allow FreeBSD packages to be installed. As documented by Justin Silver, this requires modifying two files to enable access to the FreeBSD repository. SSH to your TrueNAS box and do the following.

Disable local packages:

sudo vi /usr/local/etc/pkg/repos/local.conf
# Change "enabled: yes" to "enabled: no" to turn off access to the local packages repo

Enable FreeBSD packages:

sudo vi /usr/local/etc/pkg/repos/FreeBSD.conf
# Change "enabled: no" to "enabled: yes" to allow access to the FreeBSD packages repo
Change two files to allow access to FreeBSD packages

Now you will be able to install any FreeBSD package using the native pkg utility. This will not persist following a reboot, so updating ZeroTier won’t be possible without going through these steps again!

Install ZeroTier on TrueNAS 12

Assuming you have already set up ZeroTier and have a network ID, type the following in your TrueNAS terminal to install and configure the FreeBSD ZeroTier package:

sudo pkg install zerotier
sudo /usr/local/sbin/zerotier-one -d
sudo /usr/local/bin/zerotier-cli join <your network ID>

If all goes as expected, your TrueNAS box will now show up in your ZeroTier Central interface. Accept it and (optionally) manually assign an IP address.

Use ifconfig to validate that the interfaces are up, and type sudo /usr/local/bin/zerotier-cli listnetworks to ensure that any networks show “OK”. Next, test connectivity by pinging your TrueNAS machine from another ZeroTier client and vice-versa. If everything went OK you should have no trouble accessing your file server from anywhere!

Make ZeroTier Persistent on TrueNAS 12

But there’s still one big issue with TrueNAS: It wipes all this configuration after every reboot! So you’ll have to re-start the ZeroTier daemon and re-join all your networks each time you reboot. That’s a bummer.

If you want to make ZeroTier (or any other service on TrueNAS) persistent across reboots you have to do some black magic to override this behavior.

The following is dangerous and could result in a non-bootable system. Just like visiting Planet Genesis in Star Trek III, modifying TrueNAS like this is forbidden!

The TrueNAS developers really don’t want people mucking about with FreeBSD, and for good reason. Making changes to the OS is a great way to ruin a perfectly good system install! But it is possible to modify the configuration in a way that persists, and that’s what we’re going to do. Proceed with caution!

ZeroTier uses a few components in different places, some of which won’t be touched by a TrueNAS reboot. The binaries in /usr/local/sbin and /usr/local/bin are safe, but the configuration files in /var/db/zerotier-one and the daemon setup won’t survive a reboot.

We need to add a ZeroTier script to /etc/local/rc.d and add an enable to /etc/rc.local so the daemon will start on boot. Thankfully, ChanceM has put in the work for pfSense (which is also FreeBSD based) and we can use his zerotier rc script!

# Go to https://github.com/ChanceM/pfSense-pkg-zerotier/blob/master/zerotier and copy the text of that file

sudo vi /etc/local/rc.d/zerotier
# Paste in the text and save with :wq

# Make it executable
sudo chmod 555 /etc/local/rc.d/zerotier

# Test your new ZeroTier service
sudo service zerotier stop
sudo service zerotier start

Now we’ll set FreeBSD to start the ZeroTier daemon automatically on reboot.

sudo vi /etc/rc.conf

# add the following line right before nginx_enable:
zerotier_enable="Yes"

Before you proceed, check that your ZeroTier configuration is 100% working!

TrueNAS stores the persistent configuration in /conf/base and uses this to wipe the /etc, /mnt, and /var directories on boot. You can modify /conf/base and make changes to the config using the following commands.

# Before proceeding, get ZeroTier installed and join any and all networks you want to persist!

# back up the ZeroTier components that need to persist
cd / ; sudo tar -cvf ~/zerotier.tar etc/rc.conf etc/local/rc.d/zerotier var/db/zerotier-one
# make the root filesystem writable
sudo mount -uw /
# restore our configuration to the persistent area
cd /conf/base
sudo tar -xvpf ~/zerotier.tar

That’s it! ZeroTier should persist across a reboot!

It’s also likely that upgrading to a new version of TrueNAS will wipe out some or all of this configuration, but the zerotier.tar file we created above should be a good backup. But be careful because restoring it will blow away the contents of rc.conf and that could be bad!

Time Machine from Anywhere with ZeroTier and TrueNAS

My next step is to enable Time Machine backups from my various Mac machines to my TrueNAS box. I created a second ZeroTier network for this so I can have better control over the process: Time Machine starts automatically when you are “on network” with the target server but this isn’t always desirable when you’re connected via LTE or other expensive or slow networks. Since it’s simple to have multiple ZeroTier networks configured and running at once, I can connect to or disconnect from my Time Machine network to allow backups to happen.

Once the Time Machine network is set up, I connect to the fileserver using the ZeroTier Time Machine network IP address and configure Time Machine on my Mac to use this as a target. After this, all I have to do is connect to the Time Machine network in ZeroTier and my Mac will see the file server and begin backing up on a regular basis!

I actually haven’t gotten this working yet because I’m having issues backing up to TrueNAS shares. But I was able to get it working from one Mac to another, so it ought to work fine. The issue is TrueNAS not ZeroTier.

Stephen’s Stance

Don’t do this. Seriously, if you’re wondering if you should enable ZeroTier natively on TrueNAS but aren’t sure about all this, just stop now. I’ve been a UNIX sysadmin for over 25 years, and I’m extremely comfortable mucking about with systems, but most people probably aren’t. Also I don’t really have time to debug your particular configuration, so please don’t expect this of me.

If you’re a UNIX nerd like me, though, this is an effective way to install ZeroTier natively on TrueNAS. It’s not perfect (the ZeroTier interfaces don’t show up in TrueNAS Network Summary, for example) but it’s definitely usable! And maybe all this will help others wondering how to install software and persist across reboots on TrueNAS.

You might also want to read these other posts...

  • How To Connect Everything From Everywhere with ZeroTier
  • Liberate Wi-Fi Smart Bulbs and Switches with Tasmota!
  • Electric Car Over the Internet: My Experience Buying From…
  • Tortoise or Hare? Nvidia Jetson TK1
  • Introducing Rabbit: I Bought a Cloud!

Filed Under: Apple, Everything, Terabyte home Tagged With: FreeBSD, FreeNAS, iXsystems, pfSense, Time Machine, TrueNAS, VPN, ZeroTier

Primary Sidebar

Private information is practically the source of every large modern fortune.

Oscar Wilde

Subscribe via Email

Subscribe via email and you will receive my latest blog posts in your inbox. No ads or spam, just the same great content you find on my site!
 New posts (daily)
 Where's Stephen? (weekly)

Download My Book


Download my free e-book:
Essential Enterprise Storage Concepts!

Recent Posts

How To Install ZeroTier on TrueNAS 12

February 3, 2022

Scam Alert: Fake DMCA Takedown for Link Insertion

January 24, 2022

How To Connect Everything From Everywhere with ZeroTier

January 14, 2022

Electric Car Over the Internet: My Experience Buying From Vroom

November 28, 2020

Powering Rabbits: The Mean Well LRS-350-12 Power Supply

October 18, 2020

Tortoise or Hare? Nvidia Jetson TK1

September 22, 2020

Running Rabbits: More About My Cloud NUCs

September 21, 2020

Introducing Rabbit: I Bought a Cloud!

September 10, 2020

Remove ROM To Use LSI SAS Cards in HPE Servers

August 23, 2020

Test Your Wi-Fi with iPerf for iOS

July 9, 2020

Symbolic Links

    Featured Posts

    The Fat Middle: Today’s Enterprise Storage Array

    August 31, 2014

    Cisco’s Trojan Horse

    September 15, 2014

    Thinking About Storage In a New Way, From Cloud to Flash, with Dropbox and Fusion-io

    July 23, 2013

    Replacing Google Reader With Feedbin and Reeder

    May 5, 2013

    GPS Time Rollover Failures Keep Happening (But They’re Almost Done)

    April 6, 2019

    ZFS Is the Best Filesystem (For Now…)

    July 10, 2017

    Preserving Your Credibility Is Your Prime Directive

    June 4, 2012

    Sony QX100 Lens Camera: Ruined by a Flaky iOS App

    October 7, 2013

    Follow the Yellow Brick Road to the Software-Defined Future

    November 29, 2012

    From Kipling’s Dirigibles to the Jet Age

    May 13, 2012

    Footer

    Legalese

    Copyright © 2022 · Log in