Zerotier DNS Manager

zerotier Jun 25, 2020

Zerotier

I have been using Zerotier to network all of my computers for a little while now. I discovered it when I wanted to play video games remotely using Moonlight. It is a very useful networking tool that is easy to use, easy to manage, and runs on every kind of computer/os combination I have available to me.

It basicaly works by creating a virtual LAN network that interconnects machines you join to your private or public network. I am currently using it in my Personal Cloud Setup as well as to manage my DigitalOcean Droplet that runs my website and various other projects like the moonlight api

My network has been growing. I have added several Raspberry Pi computers and continued to set up Zerotier on other machines I use. I have been managing the network name resolution manually with my hostfile and my ssh config files, but with so many machines on my private network now that was getting tedious. They were never in sync and they are always changing as I add and remove machine from my Zerotier private network.

So I decided the other day to figure out this problem.

ZTDNS

I enjoy writing code in javascript. NodeJS runs on all kinds of computers and there are docker containers ready for me to dump one of my projects into a new layer and publish. So naturally I chose javascript for this project.

I manage my domain name via AWS Route53. I have a single hosted zone for this domina name. I knew AWS had great SDKs for almost every programming language so no problem there.

Zerotier also has an API that you can use to get information about your networks and network members.

The basic gist of the code is this:

  1. Grab a list of Zerotier network members names and IP addresses
  2. Grab a list of existing DNS records from Route53
  3. Filter the DNS records in some way so we are only looking at Zerotier related DNS records
  4. Compare the lists with each other and either create or delete records based on what was added or deleted or changed
  5. Rinse, Repeat...

The only real question was how to classify the records in Route53 as Zerotier related records. I decided to use <membername>.zt.example.com using the .zt. to filter. This seems to be working well.

This little project did not take very long and I am very happy with the results. I am now able to

ssh blah@<membername>.zt.example.com

And access my machines anywhere. They are obviously not publically accessible but any member machine of my network can get to any of the others with zero configuration.

Thanks for reading! If you have any questions or suggestions please check out the Github Repo or hit me up on Twitter or reddit in r/zerotier

Dave York

Father and computer nerd.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Background Photo by Guido Coppa on Unsplash
Photo by Marvin Meyer on Unsplash