Join and leave known networks by device name


My admin workstation is authorized on multiple networks. However, it is not desirable to be online in all of them all the times - I should join the specific network only when requested by a client.

This scenario is virtually impossible to fulfill currently when I have to use network IDs on Linux.

I think the ideal solution would be to join known networks by device name as specified in my local devicemap file. Something like:

zerotier-cli join --devicemap evilcorp

Ability to join network by network name would help too, but it’s not perfect as it can change without my prior knowledge.

Something more friendly is needed yeah. I’d probably make some shell wrapper for now?

Side note: There is a bash completion thing but you have to place it in your system yourself. The installer doesn’t do it. I don’t remember where the file goes. This helps with typing those long network ids.

I was using this bash-completion script and it is good, it helps.
But now, when I have 15-20 networks that I join and leave on regular basis, these long randomly looking thingies don’t tell me anything and I have to look them up it devicemap anyways.

As I said - for me devicemap should be the source as I have a full control over it. Network names, as seen on the Controller, can change anytime and that can be problematic. And I guess it would be much easier to put up a script that uses devicemap.

1 Like

You could use bash aliases

alias ztjoin-evilcorp=sudo zerotier-cli join $EvilCorpNetworkID
alias ztleave-evilcorp=sudo zerotier-cli leave $EvilCorpNetworkID
alias ztjoin-othercorp=sudo zerotier-cli join $OtherCorpNetworkID
alias ztleave-othercorp=sudo zerotier-cli leave $OtherCorpNetworkID
1 Like

Good idea, thanks! I will do that for now.

For future reference here is how I got it working on Ubuntu with default shell.

Add this to ~/.bashrc file:

if [ -f $HOME/.aliases-zt ]; then
    source $HOME/.aliases-zt

Add this to ~/.aliases-zt file:

alias ztjoin-evilcorp='sudo zerotier-cli join XXXXXXXXXXXXXXXX'
alias ztleave-evilcorp='sudo zerotier-cli leave XXXXXXXXXXXXXXXX'

alias ztjoin-othercorp='sudo zerotier-cli join YYYYYYYYYYYYYYYY'
alias ztleave-othercorp='sudo zerotier-cli leave YYYYYYYYYYYYYYYY'