Skip to content

Instantly share code, notes, and snippets.

@mgttt
Last active July 18, 2020 02:58
Show Gist options
  • Select an option

  • Save mgttt/4e461704312fbc5b5f73a0121e70d993 to your computer and use it in GitHub Desktop.

Select an option

Save mgttt/4e461704312fbc5b5f73a0121e70d993 to your computer and use it in GitHub Desktop.
zerotier

https://github.com/zyclonite/zerotier-docker

#sudo 
docker run --name zerotier-one --device=/dev/net/tun --net=host --cap-add=NET_ADMIN --cap-add=SYS_ADMIN -v /var/lib/zerotier-one:/var/lib/zerotier-one zyclonite/zerotier &
  
docker ps

docker exec zerotier-one zerotier-cli join 8056c2e21c000001
docker exec zerotier-one zerotier-cli listnetworks

install and run on win

https://github.com/wanjochan/misctools/blob/d8d89dd4153f22150cd5a175066e2f42a27838a5/wget_and_curl/quick_wget.md

init zt (mostly in docker)

#!/bin/bash

chmod 0666 /dev/net/tun

# default earth network
if [ ! -n "$ENV_NETWORK_P2P" ]; then
	echo ENV_NETWORK_P2P is not set 
	exit
fi

echo ENV_NETWORK_P2P=$ENV_NETWORK_P2P

zerotier-one -d

sleep 3

zerotier-cli join $ENV_NETWORK_P2P

while true; do
#	export HOST_IP=`zerotier-cli listnetworks | grep "${ENV_NETWORK_P2P}" | awk '{print \$NF}' | sed "s/-//" | sed "s/\/.*$//" `
	export HOST_IP=`zerotier-cli listnetworks | grep "${ENV_NETWORK_P2P}" | awk '{print \$NF}' | sed "s/-//" | sed "s/^.*,//" | sed "s/\/.*$//" `
	if [ ! -n "$HOST_IP" ]; then
		zerotier-cli listnetworks
	else
		break
	fi
	sleep 3
done

echo HOST_IP=$HOST_IP

echo HOSTNAME=$HOST_IP >> ~/.bashrc
echo HOSTNAME=$HOST_IP >> /etc/environment
echo HOSTNAME=$HOST_IP >> /etc/bash.bashrc
echo HOSTNAME=$HOST_IP >> /etc/profile

echo HOST_IP=$HOST_IP >> ~/.bashrc
echo HOST_IP=$HOST_IP >> /etc/environment
echo HOST_IP=$HOST_IP >> /etc/bash.bashrc
echo HOST_IP=$HOST_IP >> /etc/profile

echo NOTES: manually do it if want to get new ip:
echo rm -f /var/lib/zerotier-one/identity.*

#ping $HOST_IP
top

@mgttt
Copy link
Copy Markdown
Author

mgttt commented Jan 17, 2020

members_s=`curl -H "Authorization: Bearer ${ZT_TOKEN}" https://my.zerotier.com/api/network/${ZT_NETWORK}/member`
echo $members_s
echo $members_s | jq '.[]|select(.online==true)|[.id,.lastOnline,.physicalAddress,.config.ipAssignments,.name]'

@mgttt
Copy link
Copy Markdown
Author

mgttt commented Jan 28, 2020

ubuntu: Quick install and join earth

curl -s https://install.zerotier.com | sudo bash
sudo zerotier-cli join 8056c2e21c000001
sudo zerotier-cli listnetworks

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