What are we connecting?
Several offices with changing Internet connectivity need access to each other's services without a public VPN listener at every branch. ZeroTier coordinates membership and routes for a private virtual network. This guide connects distinct MikroTik and Ubuntu LANs. Authorizing a member only admits it to that network; gateways, return routes and service permissions still need explicit configuration.
Use RouterOS 7 and Ubuntu Server 24.04 LTS for these examples. Run Linux commands in Bash and RouterOS commands in WinBox New Terminal. Replace the sample network ID before starting and rehearse the commands on your own test devices before deployment.
ZeroTier, plain WireGuard and Tailscale
| System | Coordination and trust | Connectivity/routing | Multi-site operation |
|---|---|---|---|
| ZeroTier | Network controller authorizes nodes, managed addresses/routes and flow policy | Virtual Ethernet; encrypted peer links; NAT traversal can fall back to relay | Routed gateways or deliberate bridging; RouterOS package architecture limits |
| WireGuard alone | Administrators exchange keys and configure routes/policy; no coordination service | Encrypted L3 UDP; requires a reachable endpoint or designed hub | Simple fixed site pairs; no automatic mesh, identity directory or relay |
| Tailscale | Coordination service distributes WireGuard peer information with identity/access policy | L3 mesh with NAT traversal/DERP relay; subnet routers advertise approved routes | Identity-managed routed sites; no native Ethernet broadcast extension |
Check your router first
The MikroTik ZeroTier package is available for ARM and ARM64. Check architecture-name and RouterOS version; do not assume that CHR, x86 or MIPS can install it. Download the extra package for the exact installed RouterOS version and architecture, upload the zerotier NPK through Files and reboot during a maintenance window. Confirm it in the package list.
/system resource print
/system package print
/export file=before-zerotierKeep a configuration export and use Safe Mode (Ctrl+X) for routing and firewall edits after reboot. On unsupported MikroTik hardware, an Ubuntu gateway on the LAN can run ZeroTier; we cover that option below.
Create a private network and plan addresses
Create a private network in ZeroTier Central and copy its 16-character hexadecimal Network ID. Choose an unused managed subnet, here 10.147.20.0/24, with its on-link managed route. Authorize only known members. Assign the following fixed managed addresses to the correct node IDs; avoid allocating the same address twice.
ZeroTier subnet: 10.147.20.0/24
Router A: 10.147.20.1 LAN A: 192.168.10.0/24
Router B: 10.147.20.2 LAN B: 192.168.20.0/24
Router C: 10.147.20.3 LAN C: 192.168.30.0/24
Ubuntu: 10.147.20.10LANs and the overlay must not overlap each other or existing VPNs. These are lab addresses. Each MikroTik is already the default gateway of its own LAN. A shared 192.168.1.0/24 in every office is not routable as three distinct destinations; renumber it or design a separate address translation scheme.
The controller governs joining and policy distribution; it is not an independent HA guarantee. Previously configured peers may continue during an outage, but do not assume that behavior is guaranteed for your deployment. Record network ID, authorized node IDs, addresses, routes and flow rules, and test unauthorized-member rejection and restrictive flow rules alongside gateway firewalls.
Purpose: Make one private membership/address/route authority.
Expected result: Each authorized node has the planned unique managed IP.
Verification: Compare node IDs and address assignments before installing LAN managed routes.
Failure analysis: Check a public network setting, duplicate allocation or unintended default route.
Rollback: Withdraw only new routes/authorizations; retain the original controller configuration.
Join MikroTik to the network
Repeat on A, B and C. The standard package provides instance zt1; inspect it before enabling. If the name differs, substitute the actual instance name. Keep default-route import off for ordinary inter-office connectivity.
/zerotier print
/zerotier enable zt1
/zerotier interface add name=zt-office instance=zt1 network=0123456789abcdef allow-managed=yes allow-default=no
/zerotier interface print detail
/ip address printAuthorize each router in Central and assign its planned managed IP. Do not manually add the same IP in RouterOS when Central already assigns it. Wait for configuration delivery, then inspect the interface and addresses again.
RouterOS ZeroTier commands and properties
Purpose: Join the installed instance without importing an internet default route.
Expected result: The authorized interface receives its unique managed address.
Verification: Print the ZeroTier interface and IP routes after Central authorization.
Failure analysis: Check exact NPK version/architecture, instance state and member node ID.
Rollback: Disable only zt-office; withdraw managed routes before removing a gateway.
Install and join on Ubuntu
Save the official installer to a file and inspect it before running it with sudo. It configures the repository and installs ZeroTier One. If configuration management owns the host, perform package installation through that existing workflow so configuration ownership stays clear.
sudo apt update
sudo apt install -y curl ca-certificates
curl -fsSL https://install.zerotier.com/ -o zerotier-install.sh
less zerotier-install.sh
sudo bash zerotier-install.sh
sudo systemctl enable --now zerotier-one
sudo zerotier-cli join 0123456789abcdef
sudo zerotier-cli set 0123456789abcdef allowManaged=1
sudo zerotier-cli set 0123456789abcdef allowDefault=0
sudo zerotier-cli info
sudo zerotier-cli listnetworksAuthorize Ubuntu and assign 10.147.20.10 in Central. listnetworks shows the actual zt interface name; copy that name for the examples below. ACCESS_DENIED usually means authorization is missing. ONLINE describes the node, while OK in listnetworks describes this network membership.
Official Linux installation guidance
Purpose: install one persistent zerotier-one service and enroll its node. Expected result: ONLINE for the node and OK for the authorized network. Verification: listnetworks must show the planned 10.147.20.10 and the actual interface. Failure analysis: ACCESS_DENIED concerns network authorization, while OFFLINE concerns transport/service state. Rollback: use zerotier-cli leave with your network ID; keep node identity if rejoining is intended.
First test: Ubuntu to router
Allow only the intended management traffic on the overlay. On A, the following allows ping from Ubuntu and optionally SSH/WinBox from that same host. Use equivalent rules on B and C. Place them before the applicable input drop; do not add the entire overlay to a trusted LAN list.
/ip firewall filter add chain=input action=accept in-interface=zt-office src-address=10.147.20.10 protocol=icmp comment="ZT Ubuntu ping"
# Optional management access
/ip firewall filter add chain=input action=accept in-interface=zt-office src-address=10.147.20.10 protocol=tcp dst-port=22,8291 comment="ZT Ubuntu management"
/ping 10.147.20.10 count=5If UFW is already enabled on Ubuntu, allow SSH only from router A over the actual ZeroTier interface. RouterOS input rules protect the router itself; they do not authorize traffic through it to LAN hosts. Check /ip service address restrictions as well when management connections fail.
# Replace with the interface shown by listnetworks
ZT_IF=ztabcdefgh
sudo ufw status verbose
sudo ufw allow in on "$ZT_IF" from 10.147.20.1 to any port 22 proto tcp
ping -c 4 10.147.20.1
ip -br addressUbuntu to the LAN behind MikroTik
In Central add destination 192.168.10.0/24 via 10.147.20.1. Ubuntu with allowManaged enabled should learn it. On A allow the intended service to a specific LAN server. This example opens HTTPS to 192.168.10.50; change it to your real host and service.
/ip firewall filter add chain=forward action=accept in-interface=zt-office src-address=10.147.20.10 dst-address=192.168.10.50 protocol=tcp dst-port=443 comment="ZT Ubuntu to LAN HTTPS"Place the rule before forward drops and ensure an established,related accept rule allows replies. The LAN server must return 10.147.20.0/24 traffic through A; if another router is its gateway, add that return route there. Keep inter-site traffic free of NAT. A masquerade limited to WAN normally already excludes zt-office.
ip route get 192.168.10.50
curl --connect-timeout 5 -I https://192.168.10.50The route should point through the virtual network to gateway A. Separate an HTTPS certificate error from a TCP failure and use the real service name for certificate validation. If a broad masquerade also matches this traffic, put a narrowly scoped srcnat action=accept exception before it with the exact source and destination.
Purpose: advertise LAN A through its actual gateway and permit one HTTPS service. Expected result: Ubuntu selects 10.147.20.1 for 192.168.10.50. Verification: route get, a real hostname-based HTTPS request and router forward counters. Failure analysis: a LAN server replying through another default gateway creates asymmetry even if the overlay ping works. Rollback: withdraw the managed route and disable its scoped HTTPS rule; do not add masquerade as a substitute for understanding the reply path.
Connect two or several MikroTik LANs
For two offices use the first two managed routes; for three add the third. All routers join the same private network, keep their planned overlay addresses and import managed routes. No separate pairwise tunnel configuration is needed.
# Managed Routes in Central: Destination -> Via
192.168.10.0/24 -> 10.147.20.1
192.168.20.0/24 -> 10.147.20.2
192.168.30.0/24 -> 10.147.20.3On every router inspect the route table. Its own connected LAN should remain directly connected; remote LANs should use the correct ZeroTier peer. If managed routes are intentionally disabled, manually add only remote LAN routes instead. Do not combine both methods unnecessarily.
# Manual alternative on A only
/ip route add dst-address=192.168.20.0/24 gateway=10.147.20.2
/ip route add dst-address=192.168.30.0/24 gateway=10.147.20.3
/ip route print detailFor a lab where all three LANs may communicate, add this list and rules on EACH router. Replace bridge with its actual LAN interface, put these before drops, and keep established,related reply handling. Production rules should narrow source hosts and destination services to the required access.
/ip firewall address-list add list=zt-sites address=192.168.10.0/24
/ip firewall address-list add list=zt-sites address=192.168.20.0/24
/ip firewall address-list add list=zt-sites address=192.168.30.0/24
/ip firewall filter add chain=forward action=accept in-interface=bridge out-interface=zt-office src-address-list=zt-sites dst-address-list=zt-sites comment="LAN to remote sites"
/ip firewall filter add chain=forward action=accept in-interface=zt-office out-interface=bridge src-address-list=zt-sites dst-address-list=zt-sites comment="Remote sites to LAN"Test from a real PC in A to a real server in B and C, then test the reverse direction. A router-originated ping skips its forward chain. Keep WAN NAT confined to WAN; if broad NAT exists, place site-to-site srcnat accept exceptions before it.
Purpose: Advertise three unique LANs with their correct gateways.
Expected result: Each gateway retains its connected LAN and routes remote LANs via peers.
Verification: Test hosts in A/B/C both ways; inspect routes and forward counters.
Failure analysis: Check asymmetry and broad NAT before replacing gateway routes.
Rollback: Withdraw the three added managed routes and disable only new site permissions.
Ubuntu as a gateway for unsupported routers
Put Ubuntu on LAN A at 192.168.10.5, with managed IP 10.147.20.10. Advertise 192.168.10.0/24 via 10.147.20.10 instead of via A. The MikroTik remains the LAN gateway and needs routes for the overlay and remote offices via Ubuntu. Do not advertise the same LAN via two gateways in this basic example.
# MikroTik A: alternative topology
/ip route add dst-address=10.147.20.0/24 gateway=192.168.10.5
/ip route add dst-address=192.168.20.0/24 gateway=192.168.10.5
/ip route add dst-address=192.168.30.0/24 gateway=192.168.10.5echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/90-zerotier-routing.conf
sudo sysctl --system
# Substitute actual LAN and ZeroTier interfaces; UFW must already be configured
LAN_IF=ens18
ZT_IF=ztabcdefgh
sudo ufw route allow in on "$ZT_IF" out on "$LAN_IF" from 192.168.20.0/24 to 192.168.10.0/24
sudo ufw route allow in on "$LAN_IF" out on "$ZT_IF" from 192.168.10.0/24 to 192.168.20.0/24Repeat the two scoped UFW forwarding rules for LAN C. For overlay-host access, add a separate rule from 10.147.20.0/24 to the required LAN service. If UFW is inactive or another firewall manages the host, configure equivalent rules there. No NAT is required when return routes exist. After reboot verify forwarding, firewall and routes again.
# Ubuntu gateway: complete the LAN C forwarding pair too
sudo ufw route allow in on "$ZT_IF" out on "$LAN_IF" from 192.168.30.0/24 to 192.168.10.0/24
sudo ufw route allow in on "$LAN_IF" out on "$ZT_IF" from 192.168.10.0/24 to 192.168.30.0/24
sysctl net.ipv4.ip_forward
ip route get 192.168.20.50
sudo ufw status numberedThis alternative replaces A as the ZeroTier LAN gateway; remove the former Central route via 10.147.20.1. Expected result: LAN A replies through Ubuntu for remote prefixes without source NAT. Failure analysis: confirm the MikroTik route points to 192.168.10.5 and Ubuntu has both LAN and overlay routes; strict reverse-path filtering needs a symmetric route design. Rollback: restore the original Central next hop and MikroTik routes first, then disable Ubuntu forwarding/remove only this sysctl file and scoped UFW rules.
Mesh, hub, bridge and internet exit
The multi-office routes above let each office reach the others. Putting all members in one network does not force packets through a central router. To require hub inspection, design separate spoke networks or explicit routes and access policy through a hub; the hub needs forwarding, return routes and enough capacity. Confirm the actual traffic path.
Bridge is for a genuinely shared Ethernet segment, broadcasts or equipment that requires Layer 2. In a separate lab use a spare LAN port and a dedicated bridge, authorize Ethernet bridging in Central, use unique MACs, one DHCP server and loop prevention. Do not bridge your management or WAN port. The routed commands above are not a Layer 2 bridge recipe.
Separate Layer 2 bridging guide
Internet exit is optional and a separate topology. Advertise 0.0.0.0/0 via the exit node overlay IP; only clients that should use it enable allowDefault. The gateway needs scoped overlay-to-WAN forwarding and NAT for IPv4. For Ubuntu as an exit node, follow the official guide, preserve public endpoint reachability, check DNS and test from a spare client first.
# Ubuntu client only; after the exit gateway is configured
sudo zerotier-cli set 0123456789abcdef allowDefault=1
# Return to normal local internet routing
sudo zerotier-cli set 0123456789abcdef allowDefault=0Official exit node configuration
For IPv6, assign a distinct overlay prefix and distinct LAN prefixes, then add IPv6 routes and IPv6 firewall policy at both ends. IPv4 firewall rules do not protect IPv6. Internet exit additionally needs usable routed global IPv6 space; copying IPv4 NAT commands is not sufficient.
Back up identity and withdraw access deliberately
A ZeroTier node identity is not interchangeable with its network ID. On Ubuntu, identity.secret in /var/lib/zerotier-one authenticates the node. Back up that directory privately while the service is stopped; protect its identity and network configuration. Do not run a restored identity on two live machines. Losing it produces a new node ID that must be reauthorized and assigned the old routes/address deliberately.
sudo bash <<'EOF'
set -euo pipefail
umask 077
backup_dir="/var/backups/zerotier/$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir"
systemctl stop zerotier-one
trap 'systemctl start zerotier-one' EXIT
tar -czf "$backup_dir/node-state.tar.gz" -C /var/lib zerotier-one
tar -tzf "$backup_dir/node-state.tar.gz" > "$backup_dir/archive-list.txt"
EOF
# Leave only the selected network on Ubuntu, after withdrawing its routes
sudo zerotier-cli leave 0123456789abcdef/zerotier interface disable [find where name=zt-office]For a gateway retirement, withdraw LAN routes and forwarding permissions before deauthorizing the member. For a compromise, deauthorize immediately and investigate other access paths; check existing session termination rather than assuming revocation is instantaneous everywhere. Preserve a MikroTik encrypted configuration backup and documented Central policy; verify identity preservation in a spare-device restore, since an export alone is insufficient evidence.
A practical final check
Accept the setup against the branch requirement: check member virtual IPs, a real service from Ubuntu, LAN connectivity in both directions and each office's ordinary Internet access. Repeat after reboot. Distinct prefixes and correct routes meet many office needs; add bridging or a changed default route only for a defined requirement.
When it connects but does not work
Investigate each symptom at its layer. A missing virtual IP calls for checking member approval, managed IP assignment and allowManaged. Successful virtual ping with failed LAN access calls for managed routes, forward rules, the server firewall and return gateway. For one-way access, inspect return routes and counters before treating NAT as the first answer.
sudo zerotier-cli listnetworks
sudo zerotier-cli peers
sudo systemctl status zerotier-one --no-pager
sudo journalctl -u zerotier-one -n 50 --no-pager
ip route
sudo ufw status verbose/zerotier interface print detail
/ip route print detail
/ip firewall filter print stats
/ip firewall nat print statsSlow links may be relayed rather than direct. CGNAT or restrictive NAT can affect peer connectivity; ZeroTier is not a promise of direct connectivity on every ISP. Check UDP reachability and peer state. Do not assume allowing only destination UDP 9993 covers every peer path, and do not expose management ports on WAN to solve this.
Router and NAT troubleshooting
If short pings pass but transfers stall, investigate path MTU and packet loss before changing interface MTU everywhere. Exclude the affected traffic from FastTrack temporarily when diagnosing policy routing; do not blame FastTrack without checking counters. Test reboot persistence and revoke removed members in Central.
Questions from deployment reviews
Does Central relay every packet?
No. Coordination and data forwarding are separate. Inspect peer paths to determine direct or relayed connectivity.
Can all branches keep 192.168.1.0/24?
Not as three distinct routed destinations in this example. Renumber or deliberately design translation/VRFs; a managed route cannot distinguish identical prefixes by office name.
Vendor routing and connectivity references
ZeroTier on MikroTik architectures
Routing physical networks through a gateway