Skip to content

ZeroTier-One

ZeroTier-One is a virtual LAN service, similar to Hamachi, that allows you to have your services exposed through a VPN.

There is an official image for this service that we'll use: zerotier/zerotier.

Pre-Installation

We'll create a folder in the main user's home where all the service's data will be saved.

mkdir ~/services/networking/zerotier

Creating a Network

To create a network, simply visit My ZeroTier, login to your account (or create one if needed) and simply click on the Create Network button. This will give you a Network ID (which you should keep since we'll need this). This Network ID is what you need to share with your friends so that they can connect to your network. If you leave the network settings to be private, you may need to manually authorize new members into the network.

Docker Compose

ZeroTier-One will be run using Docker Compose. The content of the docker-compose.yml file is as follows:

services:
  vpn:
    image: zerotier/zerotier:latest
    restart: unless-stopped
    network_mode: host
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    volumes:
      - ./config/authtoken.secret:/var/lib/zerotier-one/authtoken.secret
      - ./config/identity.public:/var/lib/zerotier-one/identity.public
      - ./config/identity.secret:/var/lib/zerotier-one/identity.secret
    command: NETWORK_ID
    environment:
      TZ: America/Guayaquil

Note

Replace NETWORK_ID with your Network ID. You can add multiple networks separated by a whitespace.

Running

Start up the service with:

docker compose up -d

That's it! The service will auto-start on system startup and restart on failure.