Zerotier provide an easy way to connect multiple devices behind double NAT network together. But their public PLANET server might be a bit slower when you’re doing larger task like file transfers.
It possible to use small compute engine that already has public IP to the internet, and create a moon (relay server) for any node to orbit
Install zerotier
curl -s https://install.zerotier.com | sudo bash
Verify that Zerotier is working by running zerotier-cli
command. (If you cannot found this command, maybe it’s only exists for root user try (sudo zerotier-cli
).
Run info
command to get compute engine Node ID
zerotier-cli info
It should output something like 200 info aaaabbbbcc 1.12.0 ONLINE
, your Node ID would be aaaabbbbcc
. Keep this for later use.
Create a moon
Navigate to Zerotier configuration directory
cd /var/lib/zerotier-one/
Generate a moon configuration template
zerotier-idtool initmoon identity.public >> moon.json
Now, it’s time to edit JSON configuration. Within the file you will see a JSON field called stableEndpoints
with default value of []
. You should add your compute engine public IP to configuration file together with port to act for a moon (default 9993
)
{
...
"roots": [
{
"identity": "<leave default>",
"stableEndpoints": ["<your ipv4 address>/9993"]
}
],
...
}
Then generate a moon server file
zerotier-idtool genmoon moon.json
You should get a generated file ending with *.moon
. Now let’s move this moon file to proper directory.
mkdir -p /var/lib/zerotier-one/moons.d
mv *.moon /var/lib/zerotier-one/moons.d
And restart Zerotier service to apply changes
systemctl restart zerotier-one
Orbit a moon
For any Node that want to communicate together without public relay server, now it’s time to orbit them with a moon.
macOS / Windows
Open Terminal (macOS), or PowerShell (Windows), and execute following command to orbit a moon.
zerotier-cli orbit aaaabbbbcc aaaabbbbcc
You can see that first, and second argument of orbit
command is compute engine Node ID that we obtained when install Zerotier.
Verify that you have successfully orbit with a moon.
zerotier-cli peers
You should get an output like this indicating that a moon id aaaabbbbcc
is orbiting with path <ipv4 address>/9993
. As long as your path is not empty, you’re good to go!
<ztaddr> <ver> <role> <lat> <link> <lastTX> <lastRX> <path>
aaaabbbbcc 1.14.2 MOON 0 DIRECT 0 0 <ipv4 address>/9993
Android / iOS
In compute engine, obtain a base64 content of a moon file
base64 /var/lib/zerotier-one/moons.d/<moon filename>.moon
Open Zerotier One app, then go to Settings > Add platnet file. Then paste output of base64 to application
or create automatic QR setup with url https://joinzt.com/addplanet?v=1&planet=<base64 content>