- Run zrepl on TrueNAS
- Run ZeroTier on TrueNAS <== you are here
TrueNAS mounts /var
as a temporary filesystem (tmpfs) that is erased on every reboot. This includes the ZeroTier database located at /var/db/zerotier-one
. This guide demonstrates how to setup ZeroTier in a way that survives reboots and OS updates while preserving service zerotier XXX
functionality.
What is zerotier?
ZeroTier is:
- a mesh VPN, like Tailscale and Nebula
- a way of securely connecting your devices over the public internet in a p2p network, without the hassle of VPN
- an emulated, secure Layer 2 ethernet network that sits on top of the public internet
- absolutely awesome software
In this case I’m installing it on TrueNAS as one piece of my “secure, offsite backup of my zfs pool” puzzle.
Prerequisites
- TrueNAS (tested on version 12.0-U7)
- Web GUI access
- ssh access (with root/sudo)
- A ZeroTier network and the associated network id
Setup
Install on TrueNAS (using FreeBSD packages):
Do not reboot yet.
Setup the ZeroTier database
Start the service
Validate the database was created
Move the database to a persisted zfs dataset
Navigate to Storage
-> Pools
and create a dataset called zerotier
, e.g. tank/zerotier
mounted at /mnt/tank/zerotier
. You can put this somewhere else if you like, as long as it’s on a storage pool.
Move your db to the dataset:
Mount the dataset dir as the db where zerotier will look for it:
Join ZeroTier network
- Join:
zerotier-cli join <NETWORK-ID>
- Authorize the node in ZeroTier Central
- Make sure
ifconfig
shows the ZeroTier interface. Optional:zerotier-cli info
Persist the rc script
The ZeroTier service rc script located at /usr/local/etc/rc.d/zerotier
will get erased on reboot, just like the /var/db/zerotier-one/
directory. To fix this, we copy it to our dataset:
Create the startup script
We now need a startup script that performs the following actions on TrueNAS boot:
- Re-mount the ZeroTier DB in our dataset to the /var/db/zerotier-one directory.
- Symlink our backup copy of the rc.d service script back to the
/usr/local/etc/rc.d
directory - Re-enable the rc service (using
sysrc
) - Start the rc service
To accomplish this, use my zerotier-start.sh script:
The contents of the script are straightforward:
Validate that your zerotier dataset now looks like this:
Add zerotier-start.sh
to TrueNAS as a Pre-Init startup script:
- Go to Web GUI -> Tasks -> Init/Shutdown Scripts -> Add
- Description = “ZeroTier Startup”
- Type = “Script”
- Select /mnt/tank/zerotier/zerotier-start.sh
- When = “Pre Init” Submit
- Go to Web GUI -> Power (top-right) -> Restart (or
reboot
in shell) - ssh back in
- Verify zerotier is running:
zerotier-cli info
andifconfig
And we’re done! Your TrueNAS machine should now reliably remain on your ZeroTier network.