You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
addresses documentation problems raised in issue 35 (#36)
Responses to #35:
1. Revises `docker run` example:
* places container in host mode
* runs container detached (so it does not appear to stall)
* passes the user and group IDs for the local user (so persistent
storage is owned by the local user)
* changes default mechanism for net-filter rules to `iptables-nft`
* places image reference on a separate line
2. Revises `docker compose` service definition:
* removes deprecated `version` clause, substituting the
"here comes YAML" `---` signature
* changes default mechanism for net-filter rules to `iptables-nft`
3. Re-writes explanation of `ZEROTIER_ONE_USE_IPTABLES_NFT` to make it
clear that `true` is usually the correct option for all implementations
(not just Raspberry Pi). Also adds explicit test to confirm that the
container's net-filters are getting into the host's tables.
Opportunistic changes:
1. Updates URLs for ZeroTier Knowledge Base article (avoids redirects
when following those links).
2. Clarifies that it is the ZeroTier Knowledge Base article which
implements a half-router, and summarises the additional capabilities
of `zerotier-router`.
3. Adds cross-reference to IOTstack documentation (IMO this is more
comprehensive than anything in the ZeroTier Knowledge Base).
4. Removes extraneous `0x09` characters.
Fixes#35
Signed-off-by: Phill Kelley <34226495+Paraphraser@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README-router.md
+59-27Lines changed: 59 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,24 +4,32 @@
4
4
5
5
This is a variation built on top of the zyclonite/zerotier container which implements a local network router. It is based upon the ZeroTier Knowledge Base article:
6
6
7
-
*[Route between ZeroTier and Physical Networks](https://zerotier.atlassian.net/wiki/spaces/SD/pages/224395274/Route+between+ZeroTier+and+Physical+Networks)
7
+
*[Route between ZeroTier and Physical Networks](https://docs.zerotier.com/route-between-phys-and-virt/)
8
8
9
-
Technically, this could be described as a *half-router*:
9
+
Technically, the above approach could be described as a *half-router*:
10
10
11
11
* You can initiate connections *from* a remote client *to* devices on the LAN; but
12
12
* You can't initiate connections *to* the remote client *from* devices on the LAN.
13
13
14
+
This implementation extends the concept so that you have a choice of:
15
+
16
+
* Permitting remote clients to initiate connections with a devices on your LAN; or
17
+
* Permitting clients on your LAN to initiate connections with remote devices reachable across your ZeroTier Cloud network; or
18
+
* Both of the above (ie a full router).
19
+
14
20
### Command line example
15
21
16
22
```console
17
23
$ docker run --name zerotier-one --device=/dev/net/tun \
If omitted, `PUID` defaults to user ID 999, while `PGID` defaults to group ID 994.
92
-
101
+
93
102
These variables are only used to ensure consistent ownership of persistent storage on each launch. They do not affect how the container *runs.* Absent a `user:` directive, the container runs as root and does not downgrade its privileges.
94
103
95
104
*`ZEROTIER_ONE_LOCAL_PHYS` - a space-separated list of physical interfaces that should be configured to participate in NAT-based routing. Examples:
@@ -107,31 +116,45 @@ Note:
107
116
environment:
108
117
- ZEROTIER_ONE_LOCAL_PHYS=wlan0
109
118
```
110
-
119
+
111
120
- If your computer has both Ethernet and WiFi interfaces active and you wish to be able to route through each interface:
112
-
121
+
113
122
``` yaml
114
123
environment:
115
124
- ZEROTIER_ONE_LOCAL_PHYS=eth0 wlan0
116
125
```
117
-
126
+
118
127
This scheme could be appropriate where the physical interfaces were:
119
-
128
+
120
129
1. In the same broadcast domain (subnet). Disconnecting Ethernet would fail-over to WiFi.
121
130
2. In different broadcast domains, such as if you allocated different subnets for Ethernet and WiFi.
122
131
123
-
*`ZEROTIER_ONE_USE_IPTABLES_NFT` - controls the command the container uses to set up NAT forwarding. Example:
132
+
*`ZEROTIER_ONE_USE_IPTABLES_NFT` - controls the command the container uses to set up net-filter rules to implement packet forwarding. Example:
124
133
125
-
``` yaml
126
-
environment:
127
-
- ZEROTIER_ONE_USE_IPTABLES_NFT=true
128
134
```
129
-
130
-
- `false` means the container uses `iptables`. This is the default.
131
-
- `true` means the container uses `iptables-nft`.
135
+
environment:
136
+
- ZEROTIER_ONE_USE_IPTABLES_NFT=true
137
+
```
138
+
139
+
* `false` means the container uses `iptables-legacy`. This is the default if the variable is omitted but that is only to maintain backwards compatibility.
140
+
* `true` means the container uses `iptables-nft`. This is *generally* what you need.
141
+
142
+
The way to be absolutely certain is to start the container and then run the following command:
143
+
144
+
``` console
145
+
$ sudo nft list ruleset | grep -c "zt*"
146
+
```
147
+
148
+
Ignore any lines that start with the `#` character.
149
+
150
+
There are three possible responses:
151
+
152
+
1. An error saying that the `nft` command has not been found. Docker uses `iptables-nft` to construct its own net-filter rules so it installs the `iptables` package as a dependency which, in turn, installs `nftables` as its own dependency. For that reason, not being able to find the `nft` command generally indicates an improper installation of Docker.
153
+
2. A line-count of zero. This means the container has not been able to configure net-filter rules on the host. If that happens, try the opposite setting for this environment variable (eg `true` instead of `false`).
154
+
3. A non-zero line-count. That means the container has been able to propagate net-filter rules into the host's tables, which is what you want. The actual number is not important, just something other than zero.
155
+
156
+
The container will always come up. Once you've authorised the client in ZeroTier Central, it will be able to join your ZeroTier Cloud network. Tests like `ping` and `traceroute` that you run on the same host will always work. However, if the container is not able to propagate its net-filter rules into the host's tables, traffic *beyond* the host where the container is running will not work properly. The problem is quite subtle so it's always a good idea to check that the host has the expected net-filters.
132
157
133
-
Try `true` if NAT does not seem to be working. This is needed on Raspberry Pi Bullseye.
134
-
135
158
*`ZEROTIER_ONE_GATEWAY_MODE` - controls the traffic direction. Examples:
136
159
137
160
- Only permit traffic *from* the ZeroTier cloud *to* the local physical interfaces:
@@ -140,7 +163,7 @@ Note:
140
163
environment:
141
164
- ZEROTIER_ONE_GATEWAY_MODE=inbound
142
165
```
143
-
166
+
144
167
- Only permit traffic *from* the local physical interfaces *to* the ZeroTier cloud:
145
168
146
169
``` yaml
@@ -156,18 +179,18 @@ Note:
156
179
```
157
180
158
181
Defaults to `inbound` if omitted. Note that you will probably need one or more static routes configured in your local LAN router so that traffic originating in a local host which is not running the ZeroTier client can be directed to the gateway host.
159
-
182
+
160
183
*`ZEROTIER_ONE_NETWORK_IDS` – a space-separated list of ZeroTier network IDs.
161
184
162
185
This variable is *only* effective on first launch. There is no default if it is omitted. Examples:
163
-
186
+
164
187
- to join a single network:
165
188
166
189
``` yaml
167
190
environment:
168
191
- ZEROTIER_ONE_NETWORK_IDS=aaaaaaaaaaaaaaaa
169
192
```
170
-
193
+
171
194
Equivalent of running the following command after the container first starts:
172
195
173
196
```
@@ -194,6 +217,15 @@ Note:
194
217
195
218
For each ZeroTier container that is configured as a router, ZeroTier needs at least one *Managed Route*.
196
219
197
-
The [ZeroTier Wiki](https://zerotier.atlassian.net/wiki/spaces/SD/pages/224395274/Route+between+ZeroTier+and+Physical+Networks#Configure-the-ZeroTier-managed-route) explains how to design managed routes.
220
+
The [ZeroTier Wiki](https://docs.zerotier.com/route-between-phys-and-virt/#configure-the-zerotier-managed-route) explains how to design managed routes.
You do not have to use IOTstack just to get ZeroTier running. However, the IOTstack documentation explores several network models and is a useful guide to the concepts involved and decisions you will need to make.
0 commit comments