Skip to content

Commit 854fd6f

Browse files
authored
Merge pull request #675 from Paraphraser/20230329-zerotier-master
2023-03-29 ZeroTier - master branch - PR 1 of 2
2 parents 248c465 + 1588dbd commit 854fd6f

File tree

3 files changed

+100
-47
lines changed

3 files changed

+100
-47
lines changed
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
zerotier-client:
2-
image: zyclonite/zerotier
32
container_name: zerotier
4-
devices:
5-
- /dev/net/tun
3+
image: "zyclonite/zerotier"
4+
restart: unless-stopped
65
network_mode: host
76
volumes:
8-
- /var/lib/zerotier-one:/var/lib/zerotier-one
7+
- ./volumes/zerotier-one:/var/lib/zerotier-one
8+
devices:
9+
- "/dev/net/tun:/dev/net/tun"
910
cap_add:
10-
- NET_ADMIN
11-
- SYS_ADMIN
11+
- NET_ADMIN
12+
- SYS_ADMIN
1213

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
zerotier-router:
2-
image: zyclonite/zerotier:router
32
container_name: zerotier
4-
devices:
5-
- /dev/net/tun
3+
image: "zyclonite/zerotier:router"
4+
restart: unless-stopped
5+
environment:
6+
- TZ=${TZ:-Etc/UTC}
7+
- PUID=1000
8+
- PGID=1000
9+
# - ZEROTIER_ONE_NETWORK_IDS=yourNetworkID
10+
- ZEROTIER_ONE_LOCAL_PHYS=eth0 wlan0
11+
- ZEROTIER_ONE_USE_IPTABLES_NFT=true
12+
- ZEROTIER_ONE_GATEWAY_MODE=both
613
network_mode: host
14+
x-ports:
15+
- "9993:9993"
716
volumes:
8-
- /var/lib/zerotier-one:/var/lib/zerotier-one
17+
- ./volumes/zerotier-one:/var/lib/zerotier-one
18+
devices:
19+
- "/dev/net/tun:/dev/net/tun"
920
cap_add:
10-
- NET_ADMIN
11-
- SYS_ADMIN
12-
- NET_RAW
13-
restart: unless-stopped
14-
environment:
15-
- TZ=Etc/UTC
16-
- ZEROTIER_ONE_LOCAL_PHYS=eth0
17-
# - ZEROTIER_ONE_NETWORK_IDS=yourNetworkID
18-
- ZEROTIER_ONE_USE_IPTABLES_NFT=true
19-
- ZEROTIER_ONE_GATEWAY_MODE=both
20-
- PUID=1000
21-
- PGID=1000
21+
- NET_ADMIN
22+
- SYS_ADMIN
23+
- NET_RAW
2224

docs/Containers/ZeroTier.md

Lines changed: 75 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -231,46 +231,46 @@ To install Zerotier-router:
231231

232232
2. Use a text editor to open your `docker-compose.yml`. Find the ZeroTier service definition and the environment variables it contains:
233233

234-
``` yaml linenums="14"
235-
environment:
236-
- TZ=Etc/UTC
237-
- ZEROTIER_ONE_LOCAL_PHYS=eth0
238-
# - ZEROTIER_ONE_NETWORK_IDS=yourNetworkID
239-
- ZEROTIER_ONE_USE_IPTABLES_NFT=true
240-
- ZEROTIER_ONE_GATEWAY_MODE=both
241-
- PUID=1000
242-
- PGID=1000
234+
``` yaml linenums="5"
235+
environment:
236+
- TZ=${TZ:-Etc/UTC}
237+
- PUID=1000
238+
- PGID=1000
239+
# - ZEROTIER_ONE_NETWORK_IDS=yourNetworkID
240+
- ZEROTIER_ONE_LOCAL_PHYS=eth0 wlan0
241+
- ZEROTIER_ONE_USE_IPTABLES_NFT=true
242+
- ZEROTIER_ONE_GATEWAY_MODE=both
243243
```
244244

245245
You should:
246246

247247
1. Set your timezone.
248-
2. If necessary, change line 16 to represent your active local interfaces. Examples:
248+
2. Uncomment line 9 and replace "yourNetworkID" with your ZeroTier Network ID. This variable only has an effect the first time ZeroTier is launched. It is an alternative to executing the following command after the container has come up the first time:
249+
250+
``` console
251+
$ docker exec zerotier zerotier-cli join «NetworkID»
252+
```
253+
254+
The reason for the plural variable name ("IDS") is because it supports joining multiple networks on first launch. Network IDs are space-separated, like this:
255+
256+
``` yaml linenums="9"
257+
- ZEROTIER_ONE_NETWORK_IDS=3926d64e8ff148b3 ef7a364a687c45e0
258+
```
259+
260+
3. If necessary, change line 10 to represent your active local interfaces. Examples:
249261

250262
- if your Raspberry Pi only connects to WiFi, you would use:
251263

252-
``` yaml linenums="16"
264+
``` yaml linenums="10"
253265
- ZEROTIER_ONE_LOCAL_PHYS=wlan0
254266
```
255267

256268
- if both Ethernet and WiFi are active, use:
257269

258-
``` yaml linenums="16"
270+
``` yaml linenums="10"
259271
- ZEROTIER_ONE_LOCAL_PHYS=eth0 wlan0
260272
```
261273

262-
3. Uncomment line 17 and replace "yourNetworkID" with your ZeroTier Network ID. This variable only has an effect the first time ZeroTier is launched. It is an alternative to executing the following command after the container has come up the first time:
263-
264-
``` console
265-
$ docker exec zerotier zerotier-cli join «NetworkID»
266-
```
267-
268-
The reason for the plural variable name ("IDS") is because it supports joining multiple networks on first launch. Network IDs are space-separated, like this:
269-
270-
``` yaml linenums="17"
271-
- ZEROTIER_ONE_NETWORK_IDS=3926d64e8ff148b3 ef7a364a687c45e0
272-
```
273-
274274
3. Launch the container:
275275

276276
``` console
@@ -360,7 +360,7 @@ Enabling this feature is a two-step process:
360360
1. In ZeroTier Central, find the "Managed Routes" area and add:
361361

362362
```
363-
Destination: 0.0.0.0 (via) 10.240.0.1
363+
Destination: 0.0.0.0/0 (via) 10.240.0.1
364364
```
365365

366366
This is setting up a "default route". 10.240.0.1 is the IP address of <mark>A</mark> in the ZeroTier network.
@@ -448,6 +448,29 @@ If the second route does not make sense, think of it like this:
448448

449449
In essence, both these static routes are "set and forget". They assume catenet growth is a *possibility,* and that it is preferable to set up schemes that will be robust and not need constant tweaking.
450450

451+
### tunnelling remote clients { #topo4tunnel }
452+
453+
The diagram above for Topology 4 does not include a default route in ZeroTier Central. If you implement Topology 4 according to the diagram:
454+
455+
* traffic between <mark>G</mark> and your sites will travel via the ZeroTier Cloud (tunnelled, encrypted); but
456+
* traffic between <mark>G</mark> and the wider Internet will not be tunnelled, will not be encrypted by ZeroTier, and will reach the Internet via the ISP or cellular carrier.
457+
458+
If you want remote clients like <mark>G</mark> to use full tunnelling, you can follow the same approach as for [Topology 3](#topology3). You simply need to decide which site should used by <mark>G</mark> to reach the Internet. Having made your decision, define an appropriate default route in ZeroTier Central. For example, if <mark>G</mark> should reach the Internet via:
459+
460+
- the left-hand site, the default route should point to the ZeroTier-router running on <mark>A</mark>:
461+
462+
```
463+
Destination: 0.0.0.0/0 (via) 10.240.0.1
464+
```
465+
466+
- the right-hand site, the default route should point to the ZeroTier-router running on <mark>F</mark>:
467+
468+
```
469+
Destination: 0.0.0.0/0 (via) 10.240.0.2
470+
```
471+
472+
Once you implement the default route, everything else is the same as for [Topology 3](#topology3).
473+
451474
## Managed Routes { #managedRoutes }
452475

453476
### TL;DR { #managedRoutesTLDR}
@@ -632,6 +655,33 @@ You would need three /23 Managed Routes in ZeroTier Central. In addition, you wo
632655

633656
Sure, that third octet can range from 0..255 but it's still a finite resource which is best used wisely, particularly once you start to contemplate using ZeroTier to span multiple sites.
634657

658+
## Host mode and ports { #hostPorts }
659+
660+
The default service definition for ZeroTier-router contains the following lines:
661+
662+
``` yaml linenums="13"
663+
network_mode: host
664+
x-ports:
665+
- "9993:9993"
666+
```
667+
668+
Line 13 tells ZeroTier to run in Docker's "host mode". This means the processes running inside the container bind to the Raspberry Pi's network ports.
669+
670+
> Processes running inside non-host-mode containers bind to the container's ports, and then use Network Address Translation (NAT) to reach the Raspberry Pi's ports.
671+
672+
The `x-` prefix on line 14 has the effect of commenting-out the entire clause. In other words, the single `x-` has exactly the same meaning as:
673+
674+
``` yaml linenums="14"
675+
# ports:
676+
# - "9993:9993"
677+
```
678+
679+
The `x-ports` clause is included to document the fact that ZeroTier uses the Raspberry Pi's port 9993.
680+
681+
> Documenting the ports in use for host-mode containers helps IOTstack's maintainers avoid port conflicts when adding new containers.
682+
683+
You should **not** remove the `x-` prefix. If docker-compose complains about the `x-ports` clause, the message is actually telling you that your copy of docker-compose is obsolete and that you should upgrade.
684+
635685
## The Domain Name System { #dnsConsiderations }
636686

637687
### Normal DNS { #normalDNS }

0 commit comments

Comments
 (0)