Files
zerotierbridge/README.md

48 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

2021-08-12 16:17:57 +01:00
# ZeroTierBridge
A container to provide out-of-the-box bridging functionality to a ZeroTier network.
## Running
### Prerequisites
2021-10-27 10:52:30 +01:00
2023-10-18 08:51:03 +01:00
- Docker running as your logged in user (if `docker ps` runs then you're good, if not follow the link ->) - [Linux instructions here](https://docs.docker.com/engine/install/linux-postinstall/)
2021-10-27 10:52:30 +01:00
2021-08-13 12:44:19 +01:00
### ZeroTier UI Changes
2021-08-12 16:17:57 +01:00
Once running, log into your ZeroTier interface and approve the new device. Click the wrench next to the name and select 'Allow Ethernet Bridging.'
2021-08-12 17:11:12 +01:00
![brave_RxG5EgQinY](https://user-images.githubusercontent.com/1135584/129230874-76f80345-5389-46f7-b892-0692f41be20b.png)
2021-08-12 17:10:03 +01:00
You also need to add a static route into ZeroTier so that the traffic is routed correctly. Add this a bit larger than normal because of [longest prefix matching](https://en.wikipedia.org/wiki/Longest_prefix_match).
![brave_4wHd9zo193](https://user-images.githubusercontent.com/1135584/129230132-11bcfb72-7d9b-4b40-a4e5-72130c583077.png)
2021-08-12 16:17:57 +01:00
2021-08-13 12:44:19 +01:00
### Docker Compose
Edit the `ZT_NETWORKS` variable in `docker-compose.yml` to add your networks. Multi-arch images are published automatically; no architecture changes are needed.
2021-08-13 12:44:19 +01:00
2023-10-18 08:51:03 +01:00
Easiest way to bring up is via Docker Compose. Rename `docker-compose.yml.example` to `docker-compose.yml` and run `docker compose up -d`.
2021-08-13 12:44:19 +01:00
If you want to disable bridging, set `ZT_BRIDGE=false`. This can be done after the initial networks have been joined (just change the environment variable in the `docker-compose.yml` file and restart), as the ZeroTier config persists but IPTables forwarding is done on each container startup.
2021-08-13 12:44:19 +01:00
### OG Docker
`docker build -t zerotierbridge .`
`docker run --cap-add NET_ADMIN --cap-add NET_RAW --sysctl net.ipv4.ip_forward=1 -e ZT_NETWORKS="NETWORK_1 NETWORK_2" -e ZT_BRIDGE=true zerotierbridge:latest`
2021-08-13 12:44:19 +01:00
Add your network ID(s) into the `ZT_NETWORKS` argument, space separated.
Disable bridging by passing `ZT_BRIDGE=false`. This can be done after the initial networks have been joined (just restart the container), as the ZeroTier config persists but IPTables forwarding is done on each container startup.
2021-08-13 12:44:19 +01:00
#### Persistent Storage
2021-08-12 19:28:53 +01:00
If you would like the container to retain the same ZeroTier client ID on reboot, attach a volume as per the below.
2023-10-18 08:51:03 +01:00
`docker run --privileged -e ZT_NETWORKS=NETWORK_ID_HERE ZT_BRIDGE=true -v zt_config:/var/lib/zerotier-one/ zerotierbridge:latest`
2021-08-12 19:28:53 +01:00
#### Notes
2021-08-12 16:17:57 +01:00
If your host requires additional privileges for networking, you may need to add device and capabilities in your runtime configuration. The provided Docker Compose example includes `cap_add: [NET_ADMIN, NET_RAW]` and `sysctls` for IP forwarding.