Network Controllers
#
Self-Hosting ZeroTier Network Controllers#
Reference Docs#
READMEhttps://github.com/zerotier/ZeroTierOne/tree/master/controller
#
API clientsThere is an OpenAPI spec at https://docs.zerotier.com/openapi/servicev1.json which can be used to generate API clients in many languages.
You can browse the docs here.
#
TutorialFirst, skim the README.
We're going to use curl
to set up an example ZeroTier network. An easy way to get curl
in Windows is to install the latest version of Git, which comes with bash, curl, and other tools.
This is a low tech way to setup a controller for example purposes. You'd likely build yourself something fancier around this API.
#
AuthtokenThe authtoken.secret file in the ZeroTier home directory is required to make API calls to the controller service.
note
ZeroTier generates the token at random the first time it starts. You can change it if you want.
Lets save the token to an environment variable. We need it in all the following commands.
- Linux
- macOS
- Windows
\ProgramData\ZeroTier\One\authtoken.secret
#
Get your Node IDnote
Network IDs are based on the Node ID of the Controller. Controllers are nodes! When you join a network, your node finds the controller like it does with other nodes: by its Node ID.
#
with zerotier-cli(may need sudo)
#
with curlIt's the "Address" in the above's output.
Let's save the Node ID to an environment variable too:
or try:
#
Create a NetworkThis should return JSON for a fresh network.
note
When you post to /network/${NODEID}______
the controller generates a random Network ID for you.
See the "id" of your newly created network.
Let's save the new Network ID to an environment variable
#
List NetworksThis returns a list of Network IDs. It should include the ID returned by the create command we did in the previous step.
#
Get Network Info#
List Network MembersYou'll need another node join your network first, or this will be empty. You can use a phone, or another PC, or a VM, or a VPS...
I guess you could join the controller node to its own network, for demonstration purposes.
Save the Node ID of one of your Network Members in an env var
#
Get Member Info#
Configure the NetworkFor Nodes can talk, we need to add a Managed Route and IP Auto-Assign Range on the network. Let's make it a Private network too. Prefer Private networks.
#
Authorize a member#
Network Info Again#
Member Info Again#
Confirm from your nodesIt should say "OK PRIVATE" and have an IP address.
#
Deauthorize Member#
Delete Membercaution
You can "delete" a member, but they will show up in the output of "list member" again if the node is still online and trying to join. You should make sure to deauthorize before deleting.
#
Backup your controllerIf you want to keep these networks, copy the ZeroTier Home directory somewhere. Most importantly, the identity.secret and the controller.d directory.
#
Clean up networksYou may want to delete these networks now that you're done testing. You could use the API to delete every network.
Or you can delete the controller.d directory.
- Linux
- macOS
stop zerotier (If you're ssh'd in over zerotier, this will break your connection):
delete controller configs:
start zerotier:
stop zerotier:
delete controller configs:
start zerotier: