ZeroTier on FreeNAS

Hey guys, I recently started using ZeroTier and have been pretty impressed with all it does. I’m running FreeNAS 11.2 Stable and was initially delighted to find that FreeNAS had ZeroTier built in with this release. My delight has soured a bit when I found that the configuration is lost on each reboot. Additionally, if you reconnect after the reboot, the ID is different each time and as such gets assigned a different IP. I’m not entirely sure how to make the connection persist across reboots. This pretty much ruins my ability to use ZeroTier with FreeNAS. So far my Googling has shown me some possibilities for getting ZeroTier to start up automatically but it doesn’t address the different ID on every boot. Does anyone here have any recommendations on how to fix this?

By the way Tom, your content is outstanding! I’ve begun using several open-source projects just based on your recommendations and have been really happy with most of them. Thanks for the quality reviews you do!

1 Like

I have not done any testing with FreeNAS and ZeroTie yet, but that is interesting. When I get some time I will look to see if there is some way to specify a config file.

1 Like

Make a script containing this (changing the /path/to/folder and fake join ID obviously) and run it in Tasks > Init/Shutdown Scripts as post-init. (I run it as a command: “bash /path/to/script/myscript.sh”.)
Code:

#!/bin/bash

ln -s /path/to/folder/zerotier-one /var/db/zerotier-one
/usr/local/sbin/zerotier-one -d
sleep 1
/usr/local/bin/zerotier-cli join 1234567890abcdef

Basically, configuration gets reset upon reboot, so you have to make a symbolic link at /var/db/zerotier-one so it places all the files elsewhere, and then remake it every startup so Zerotier finds the files it needs to find when you run it again.

The sleep 1 is there because if you run the zerotier-cli command immediately afterward, it is not ready yet for some reason. Guess it needs a moment to wake up. #justlikeus

Sourced from here

That solution worked for me to get it to start up on boot but somehow the config changes on each boot still… I did have to run it as a command instead of as a script. Also I had to locate the folder on one of my ZFS pools so it wouldn’t be wiped by FreeNAS on reboot. I put both the script and the zerotier configuration folder on the pool, scheduled that script to run, and it works. However, on reboot the config is a different one showing up in ZeroTier and I have to reauthorize it and remove the old config. I suspect it’s not picking up the correct config folder?

EDIT: I figured it out. What was happening is somehow a newline character snuck in instead of the space on the path making the symbolic link. I feel dumb now. Rebooting a few more times to be sure here. Thanks for the help!

I am glad i could help . Did you make the script executable with chmod +x myscript.sh . Maybe that is why you have to run it as a command .

hi new member here, im also having issues where the config changes all the time. mind to share your solution? thanks