Skip to content

Instantly share code, notes, and snippets.

@stianl
Created May 10, 2025 12:50
Show Gist options
  • Save stianl/f1be7e3b856b1b4ac2b6cacf8673d0fa to your computer and use it in GitHub Desktop.
Save stianl/f1be7e3b856b1b4ac2b6cacf8673d0fa to your computer and use it in GitHub Desktop.
Show nodes and IP's of ZeroTier network
#!/bin/sh
# Get the network id of the first network from the service API
ZT_NWID=$(curl -s -H "X-ZT1-Auth: $(cat /var/lib/zerotier-one/authtoken.secret)" http://localhost:9993/network | jq -r '.[0].nwid')
# Get the network members of that network - output the names
MEMBERS=$(curl -s -H "Accept: application/json" -H "Authorization: token $ZT_CENTRAL_API_TOKEN" "https://api.zerotier.com/api/v1/network/$ZT_NWID/member")
# Get the name and ips of all members
NAME_IPS=$(echo $MEMBERS | jq '.[]|{name: .name, ips: .config.ipAssignments}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment