Skip to content

Instantly share code, notes, and snippets.

@laduke
Created February 25, 2019 18:41
Show Gist options
  • Save laduke/dac278deefc10c853141b5b82063b1b6 to your computer and use it in GitHub Desktop.
Save laduke/dac278deefc10c853141b5b82063b1b6 to your computer and use it in GitHub Desktop.
controller.org

Set up a controller with curl

1 Find your auth token

the authtoken.secret file

  • On Mac this is in “/Library/Application Support/ZeroTier/One”. also, the installer copies it to ~/Library/Application\ Support/ZeroTier/One
  • Windows this is usually in “\ProgramData\ZeroTier\One”. also, the installer copies it somewhere local to the installing user… I forget
  • On Linux this is usually in “/var/lib/zerotier-one”.

1.1 You can change the token if you like

2 Get your Node ID

2.1 with zerotier-cli

(may need sudo)

zerotier-cli info

2.2 with curl

curl -X GET 'http://localhost:9993/status/' -H "X-ZT1-AUTH: ${TOKEN}" 

It’s the “Address” in the above output.

3 Create a Network

curl -X POST "http://localhost:9993/controller/network/${NODEID}______" -H "X-ZT1-AUTH: ${TOKEN}" -d {}

A Network ID is the Controller’s ID + 6 more characters.

4 List Networks

curl -X GET "http://localhost:9993/controller/network/" -H "X-ZT1-AUTH: ${TOKEN}" 

5 Get Network Info

curl -X GET "http://localhost:9993/controller/network/${NWID}/" -H "X-ZT1-AUTH: ${TOKEN}" 

6 List Network Members

Have a different node join your network first.

curl -X GET "http://localhost:9993/controller/network/${NWID}/member" -H "X-ZT1-AUTH: ${TOKEN}" 

7 Get Member Info

curl -X GET "http://localhost:9993/controller/network/${NWID}/member/${MEMID}" -H "X-ZT1-AUTH: ${TOKEN}" 

8 Configure a Managed Route and IP Auto-Assign Range on the network

curl -X POST "http://localhost:9993/controller/network/${NWID}/" -H "X-ZT1-AUTH: ${TOKEN}" -d '{"ipAssignmentPools": [{"ipRangeStart": "192.168.192.1", "ipRangeEnd": "192.168.192.254"}], "routes": [{"target": "192.168.192.0/24", "via": null}], "v4AssignMode": "zt"}'

9 Authorize a member

curl -X POST "http://localhost:9993/controller/network/${NWID}/member/${MEMID}" -H "X-ZT1-AUTH: ${TOKEN}" -d '{"authorized": true}'

10 Network Info Again

curl -X GET "http://localhost:9993/controller/network/${NWID}/" -H "X-ZT1-AUTH: ${TOKEN}" 

11 Member Info Again

curl -X GET "http://localhost:9993/controller/network/${NWID}/member/${MEMID}" -H "X-ZT1-AUTH: ${TOKEN}" 

12 Delete Member

curl -X DELETE "http://localhost:9993/controller/network/${NWID}/member/${MEMID}" -H "X-ZT1-AUTH: ${TOKEN}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment