I was looking to have a member list, same as shown in portal, under a network via CLI.
meaning to be able to get all IPs that are members of my private subnet, maybe with the Metadata (description) I added, when I used the GUI dashboard, but via ZT-CLI.
my workaround was IP scanner… but it is not enough, since I had no hostnames and description, and could not figure who is who
You’ll need to create an API token in your accounts section. Here’s a quick Python script you can run from your node (can actually be run from any node) to list all of the peers and their IPs:
import requests
import json
# Replace 'insert_zerotier_central_api_token' with your actual token
token = 'insert_zerotier_central_api_token'
# Define the API endpoint URL; replace insert_network_id with your network id
url = 'https://api.zerotier.com/api/v1/network/insert_network_id/member'
# Create headers with the Authorization token
headers = {
'Authorization': f'token {token}'
}
# Send the GET request
response = requests.get(url, headers=headers)
# Check the response status code
if response.status_code == 200:
# Request was successful, you can access the response content
network_data = response.json()
for i in network_data:
print(f"{i['config']['address']} {i['config']['ipAssignments']}")
else:
# Request failed, handle the error
print(f"Failed to retrieve data. Status code: {response.status_code}")
Hi
Thanks for the reply, unfortunately I am not familiar (yet) with Python and was looking a build in CLI command/parameter.
Maybe it belongs to new feature request
There’s no built in command for this. The data you’re asking for isn’t known at the clients themselves. It’s only known by the network controller, so it’s not possible to retrieve from the client alone. You’ll have to incorporate some API calls to https://my.zerotier.com (or your self hosted controller) in order to get the member information