A Smart Ethernet Switch for Earth
Go to file
Travis LaDuke 6540107ccb
fix memory leak in macos ipv6/dns helper (#2030)
Co-authored-by: Grant Limberg <glimberg@users.noreply.github.com>
2023-07-06 12:32:10 -07:00
.github Improve validation test (#2013) 2023-05-25 10:54:26 -07:00
artwork Added 90x90 AppIcon 2019-05-01 12:53:50 -07:00
attic 1.8.1 merge of changes in master 2021-10-28 14:46:38 -04:00
ci new drone bits 2023-03-31 16:29:18 +02:00
controller don't unborrow bad connections 2023-06-08 08:45:50 -07:00
debian new drone bits 2023-03-31 16:29:18 +02:00
doc fix typos in docs, comments, and strings 2022-12-07 10:17:53 -05:00
ext docker tags change 2023-07-06 10:12:29 -07:00
include Client & Central Controller updates to support additonal OIDC features (#1848) 2023-01-19 15:39:15 -08:00
java actual fix for ANDROID-56: crash inside newNetworkConfig 2023-03-09 06:51:29 -05:00
node Allow sending all surface addresses to peer in low-bandwidth mode 2023-05-31 15:02:17 -07:00
osdep fix memory leak in macos ipv6/dns helper (#2030) 2023-07-06 12:32:10 -07:00
pkg Minor tweak to Synology Docker image script (#1936) 2023-03-24 11:58:34 -07:00
rule-compiler BSL date bump 2020-08-20 12:51:39 -07:00
service fix oidc auth url memory leak (#2031) 2023-07-06 11:27:54 -07:00
tcp-proxy 1.10.4 merge into main (#1893) 2023-03-07 16:50:34 -05:00
windows Enable RTTI in Windows build 2023-05-17 13:36:15 -07:00
zeroidc zeroidc cargo warnings (#2029) 2023-07-06 12:13:00 -07:00
.clang-format Add ZeroTier standard .clang-format -- Keeping tabs for 1.X line. Mostly based on LLVM format. 2021-05-03 13:00:30 -07:00
.dockerignore can now build centos8 docker container with Redis support 2020-05-12 15:17:57 -07:00
.drone.jsonnet new drone bits 2023-03-31 16:29:18 +02:00
.drone.yml new drone bits 2023-03-31 16:29:18 +02:00
.gitattributes force eol=crlf for driver .inf files 2020-11-25 18:22:52 -08:00
.gitignore resurrect tcp proxy 2022-12-06 11:49:12 -08:00
.kick new drone bits 2023-03-31 16:29:18 +02:00
AUTHORS.md Relicense: GPLv3 -> ZeroTier BSL 1.1 2019-08-23 09:23:39 -07:00
CMakeLists.txt Removed build flag in CMake script 2017-12-13 14:57:20 -08:00
COPYING Relicense: GPLv3 -> ZeroTier BSL 1.1 2019-08-23 09:23:39 -07:00
cycle_controllers.sh add application_name to pgbouncer connectio string 2018-12-10 12:26:20 -08:00
Dockerfile.ci more RELEASE-NOTES 2021-09-15 08:12:25 +02:00
Dockerfile.release update dockerfile.release 2022-09-13 12:23:51 -07:00
entrypoint.sh.release Fix multiple network join from environment entrypoint.sh.release (#1961) 2023-04-12 16:47:26 +02:00
LICENSE.txt BSL date bump 2020-08-20 12:51:39 -07:00
make-bsd.mk Add prometheus metrics for Central controllers (#1969) 2023-04-21 12:12:43 -07:00
make-linux.mk docker tags change 2023-07-06 10:12:29 -07:00
make-mac.mk docker tags change 2023-07-06 10:12:29 -07:00
make-netbsd.mk fix RTF_MULTICAST and g++ -w 2016-12-27 13:07:05 +01:00
Makefile new drone bits 2023-03-31 16:29:18 +02:00
objects.mk Add prometheus metrics for Central controllers (#1969) 2023-04-21 12:12:43 -07:00
OFFICIAL-RELEASE-STEPS.md Version bump -- still pre1.8 2021-08-23 11:57:12 -04:00
one.cpp 1.10.4 merge into main (#1893) 2023-03-07 16:50:34 -05:00
README.docker.md 1.10.4 merge into main (#1893) 2023-03-07 16:50:34 -05:00
README.md Update README.md 2023-07-05 13:59:23 -07:00
RELEASE-NOTES.md Release notes for 1.10.6 (#1931) 2023-03-23 12:13:53 -07:00
SECURITY.md 1.10.4 merge into main (#1893) 2023-03-07 16:50:34 -05:00
selftest.cpp fix typos (#1846) 2023-01-13 10:14:57 -05:00
update_controllers.sh update docker registry used 2019-02-08 10:40:57 -08:00
version.h 1.10.6 (#1929) 2023-03-23 13:38:22 -04:00
windows-clean.bat Revise Windows build to VS2022. 2022-06-06 19:33:35 -04:00
zerotier-cli-completion.bash Create a bash completion script. 2020-07-23 13:40:48 -07:00
zerotier-one.spec new drone bits 2023-03-31 16:29:18 +02:00

ZeroTier - Global Area Networking

This document is written for a software developer audience. For information on using ZeroTier, see the: Website, Documentation Site, and Discussion Forum.

ZeroTier is a smart programmable Ethernet switch for planet Earth. It allows all networked devices, VMs, containers, and applications to communicate as if they all reside in the same physical data center or cloud region.

This is accomplished by combining a cryptographically addressed and secure peer to peer network (termed VL1) with an Ethernet emulation layer somewhat similar to VXLAN (termed VL2). Our VL2 Ethernet virtualization layer includes advanced enterprise SDN features like fine grained access control rules for network micro-segmentation and security monitoring.

All ZeroTier traffic is encrypted end-to-end using secret keys that only you control. Most traffic flows peer to peer, though we offer free (but slow) relaying for users who cannot establish peer to peer connections.

The goals and design principles of ZeroTier are inspired by among other things the original Google BeyondCorp paper and the Jericho Forum with its notion of "deperimeterization."

Visit ZeroTier's site for more information and pre-built binary packages. Apps for Android and iOS are available for free in the Google Play and Apple app stores.

ZeroTier is licensed under the BSL version 1.1. See LICENSE.txt and the ZeroTier pricing page for details. ZeroTier is free to use internally in businesses and academic institutions and for non-commercial purposes. Certain types of commercial use such as building closed-source apps and devices based on ZeroTier or offering ZeroTier network controllers and network management as a SaaS service require a commercial license.

A small amount of third party code is also included in ZeroTier and is not subject to our BSL license. See AUTHORS.md for a list of third party code, where it is included, and the licenses that apply to it. All of the third party code in ZeroTier is liberally licensed (MIT, BSD, Apache, public domain, etc.).

Getting Started

Everything in the ZeroTier world is controlled by two types of identifier: 40-bit/10-digit ZeroTier addresses and 64-bit/16-digit network IDs. These identifiers are easily distinguished by their length. A ZeroTier address identifies a node or "device" (laptop, phone, server, VM, app, etc.) while a network ID identifies a virtual Ethernet network that can be joined by devices.

ZeroTier addresses can be thought of as port numbers on an enormous planet-wide enterprise Ethernet smart switch supporting VLANs. Network IDs are VLAN IDs to which these ports may be assigned. A single port can be assigned to more than one VLAN.

A ZeroTier address looks like 8056c2e21c and a network ID looks like 8056c2e21c000001. Network IDs are composed of the ZeroTier address of that network's primary controller and an arbitrary 24-bit ID that identifies the network on this controller. Network controllers are roughly analogous to SDN controllers in SDN protocols like OpenFlow, though as with the analogy between VXLAN and VL2 this should not be read to imply that the protocols or design are the same. You can use our convenient and inexpensive SaaS hosted controllers at my.zerotier.com or run your own controller if you don't mind messing around with JSON configuration files or writing scripts to do so.

Project Layout

The base path contains the ZeroTier One service main entry point (one.cpp), self test code, makefiles, etc.

  • artwork/: icons, logos, etc.
  • attic/: old stuff and experimental code that we want to keep around for reference.
  • controller/: the reference network controller implementation, which is built and included by default on desktop and server build targets.
  • debian/: files for building Debian packages on Linux.
  • doc/: manual pages and other documentation.
  • ext/: third party libraries, binaries that we ship for convenience on some platforms (Mac and Windows), and installation support files.
  • include/: include files for the ZeroTier core.
  • java/: a JNI wrapper used with our Android mobile app. (The whole Android app is not open source but may be made so in the future.)
  • node/: the ZeroTier virtual Ethernet switch core, which is designed to be entirely separate from the rest of the code and able to be built as a stand-alone OS-independent library. Note to developers: do not use C++11 features in here, since we want this to build on old embedded platforms that lack C++11 support. C++11 can be used elsewhere.
  • osdep/: code to support and integrate with OSes, including platform-specific stuff only built for certain targets.
  • rule-compiler/: JavaScript rules language compiler for defining network-level rules.
  • service/: the ZeroTier One service, which wraps the ZeroTier core and provides VPN-like connectivity to virtual networks for desktops, laptops, servers, VMs, and containers.
  • windows/: Visual Studio solution files, Windows service code, and the Windows task bar app UI.
  • zeroidc/: OIDC implementation used by ZeroTier service to log into SSO-enabled networks. (This part is written in Rust, and more Rust will be appearing in this repository in the future.)

Build and Platform Notes

To build on Mac and Linux just type make. On FreeBSD and OpenBSD gmake (GNU make) is required and can be installed from packages or ports. For Windows there is a Visual Studio solution in windows/.

  • Mac
    • Xcode command line tools for macOS 10.13 or newer are required.
    • Rust for x86_64 and ARM64 targets if SSO is enabled in the build.
  • Linux
    • The minimum compiler versions required are GCC/G++ 4.9.3 or CLANG/CLANG++ 3.4.2. (Install clang on CentOS 7 as G++ is too old.)
    • Linux makefiles automatically detect and prefer clang/clang++ if present as it produces smaller and slightly faster binaries in most cases. You can override by supplying CC and CXX variables on the make command line.
    • Rust for x86_64 and ARM64 targets if SSO is enabled in the build.
  • Windows
    • Visual Studio 2022 on Windows 10 or newer.
    • Rust for x86_64 and ARM64 targets if SSO is enabled in the build.
  • FreeBSD
    • GNU make is required. Type gmake to build.
    • binutils is required. Type pkg install binutils to install.
    • Rust for x86_64 and ARM64 targets if SSO is enabled in the build.
  • OpenBSD
    • There is a limit of four network memberships on OpenBSD as there are only four tap devices (/dev/tap0 through /dev/tap3).
    • GNU make is required. Type gmake to build.
    • Rust for x86_64 and ARM64 targets if SSO is enabled in the build.

Typing make selftest will build a zerotier-selftest binary which unit tests various internals and reports on a few aspects of the build environment. It's a good idea to try this on novel platforms or architectures.

Running

Running zerotier-one with -h option will show help.

On Linux and BSD, if you built from source, you can start the service with:

sudo ./zerotier-one -d

On most distributions, macOS, and Windows, the installer will start the service and set it up to start on boot.

A home folder for your system will automatically be created.

The service is controlled via the JSON API, which by default is available at 127.0.0.1 port 9993. We include a zerotier-cli command line utility to make API calls for standard things like joining and leaving networks. The authtoken.secret file in the home folder contains the secret token for accessing this API. See service/README.md for API documentation.

Here's where home folders live (by default) on each OS:

  • Linux: /var/lib/zerotier-one
  • FreeBSD / OpenBSD: /var/db/zerotier-one
  • Mac: /Library/Application Support/ZeroTier/One
  • Windows: \ProgramData\ZeroTier\One (That's the default. The base 'shared app data' folder might be different if Windows is installed with a non-standard drive letter assignment or layout.)

Basic Troubleshooting

For most users, it just works.

If you are running a local system firewall, we recommend adding a rules permitting zerotier. If you installed binaries for Windows this should be done automatically. Other platforms might require manual editing of local firewall rules depending on your configuration.

See the documentation site for more information.

The Mac firewall can be found under "Security" in System Preferences. Linux has a variety of firewall configuration systems and tools.

On CentOS check /etc/sysconfig/iptables for IPTables rules. For other distributions consult your distribution's documentation. You'll also have to check the UIs or documentation for commercial third party firewall applications like Little Snitch (Mac), McAfee Firewall Enterprise (Windows), etc. if you are running any of those. Some corporate environments might have centrally managed firewall software, so you might also have to contact IT.

ZeroTier One peers will automatically locate each other and communicate directly over a local wired LAN if UDP port 9993 inbound is open. If that port is filtered, they won't be able to see each others' LAN announcement packets. If you're experiencing poor performance between devices on the same physical network, check their firewall settings. Without LAN auto-location peers must attempt "loopback" NAT traversal, which sometimes fails and in any case requires that every packet traverse your external router twice.

Users behind certain types of firewalls and "symmetric" NAT devices may not be able to connect to external peers directly at all. ZeroTier has limited support for port prediction and will attempt to traverse symmetric NATs, but this doesn't always work. If P2P connectivity fails you'll be bouncing UDP packets off our relay servers resulting in slower performance. Some NAT router(s) have a configurable NAT mode, and setting this to "full cone" will eliminate this problem. If you do this you may also see a magical improvement for things like VoIP phones, Skype, BitTorrent, WebRTC, certain games, etc., since all of these use NAT traversal techniques similar to ours.

If a firewall between you and the Internet blocks ZeroTier's UDP traffic, you will fall back to last-resort TCP tunneling to rootservers over port 443 (https impersonation). This will work almost anywhere but is very slow compared to UDP or direct peer to peer connectivity.

Additional help can be found in our knowledge base.

Prometheus Metrics

Prometheus Metrics are available at the /metrics API endpoint. This endpoint is protected by an API key stored in authtoken.secret because of the possibility of information leakage. Information that could be gleaned from the metrics include joined networks and peers your instance is talking to.

Access control is via the ZeroTier control interface itself and authtoken.secret. This can be sent as the X-ZT1-Auth HTTP header field or appended to the URL as ?auth=<token>. You can see the current metrics via cURL with the following command:

// Linux
curl -H "X-ZT1-Auth: $(sudo cat /var/lib/zerotier-one/authtoken.secret)" http://localhost:9993/metrics

// macOS
curl -H "X-XT1-Auth: $(sudo cat /Library/Application\ Support/ZeroTier/One/authtoken.secret)" http://localhost:9993/metrics

// Windows PowerShell (Admin)
Invoke-RestMethod -Headers @{'X-ZT1-Auth' = "$(Get-Content C:\ProgramData\ZeroTier\One\authtoken.secret)"; } -Uri http://localhost:9993/metrics

To configure a scrape job in Prometheus on the machine ZeroTier is running on, add this to your Prometheus scrape_config:

- job_name: zerotier-one
  honor_labels: true
  scrape_interval: 15s
  metrics_path: /metrics
  static_configs:
  - targets:
    - 127.0.0.1:9993
    labels:
      group: zerotier-one
  params:
    auth:
    - $YOUR_AUTHTOKEN_SECRET

If your Prometheus instance is remote from the machine ZeroTier instance, you'll have to edit your local.conf file to allow remote access to the API control port. If your local lan is 10.0.0.0/24, edit your local.conf as follows:

{
  "settings": {
    "allowManagementFrom:" ["10.0.0.0/24"]
  }
}

Substitute your actual network IP ranges as necessary.

It's also possible to access the metrics & control port over the ZeroTier network itself via the same method shown above. Just add the address range of your ZeroTier network to the list. NOTE: Using this method means that anyone with your auth token can control your ZeroTier instance, including leaving & joining other networks.

If neither of these methods are desirable, it is probably possible to distribute metrics via Prometheus Proxy or some other tool. Note: We have not tested this internally, but will probably work with the correct configuration.

Available Metrics

Metric Name Labels Metric Type Description
zt_packet packet_type, direction Counter ZeroTier packet type counts
zt_packet_error error_type, direction Counter ZeroTier packet errors
zt_data protocol, direction Counter number of bytes ZeroTier has transmitted or received
zt_num_networks Gauge number of networks this instance is joined to
zt_network_multicast_groups_subscribed network_id Gauge number of multicast groups networks are subscribed to
zt_network_packets network_id, direction Counter number of incoming/outgoing packets per network
zt_peer_latency node_id Histogram peer latency (ms)
zt_peer_path_count node_id, status Gauge number of paths to peer
zt_peer_packets node_id, direction Counter number of packets to/from a peer
zt_peer_packet_errors node_id Counter number of incoming packet errors from a peer

If there are other metrics you'd like to see tracked, ask us in an Issue or send us a Pull Request!