zerotier.is
AdLuoboyunAn account comes with 1 GB of trial traffic for 24 hours, used with Clash / MihomoPays by Alipay, WeChat, cryptoGet the trialLuoboyun: 1 GB on registrationFor 24 hours, Alipay / WeChat / cryptoGet the trialAd
  1. Home
  2. Blog
  3. NAS

NAS Written

No more Synology package: use a container

ZeroTier stopped maintaining its native Synology package. TUN on DSM 7, folder, container, joining, authorizing and upgrading, plus gateway use.

The same goods in a different box
The same goods in a different box Kari Hakli, CC BY-SA 4.0

The download page says it: native packages for Synology, QNAP, ASUSTOR and Western Digital are no longer maintained, and containers are the supported way. This follows the documentation, for DSM 7.

If the old package still works, no hurry. But some DSM update may stop it, usually while you are away. Change it on a weekend at home with a second way in ready.

Before you start

  1. Turn on SSH under Control Panel, Terminal & SNMP.
  2. Install Container Manager.
  3. Log in by SSH and run sudo -i.

Give the system TUN

Loaded at every boot
echo -e '#!/bin/sh -e \ninsmod /lib/modules/tun.ko' > /usr/local/etc/rc.d/tun.sh
chmod a+x /usr/local/etc/rc.d/tun.sh
/usr/local/etc/rc.d/tun.sh
ls /dev/net/tun

The last line should print /dev/net/tun.

Start the container

The identity on a volume survives system upgrades
mkdir -p /volume1/docker/zerotier
docker run -d --name zt --restart=always --device=/dev/net/tun --net=host --cap-add=NET_ADMIN --cap-add=SYS_ADMIN -v /volume1/docker/zerotier:/var/lib/zerotier-one zerotier/zerotier-synology:latest

The official example keeps the identity in a system folder and warns that DSM updates may lose it, so here it is on a volume.

Join

With the command inside the container
docker exec -it zt zerotier-cli join NETWORK_ID
docker exec -it zt zerotier-cli listnetworks

Authorize it in the console. ZeroTier advises against Synology's own window for this container.

What you seeDo
The container keeps restartingTUN is missing, run the script
No network after a DSM upgradeIs tun.sh still there
Authorized but no pingAllow the ZeroTier subnet in Synology's firewall
  1. Stop and removethe folder stays
  2. Pull the new imagedocker pull
  3. Run it againsame command
  4. No new authorizationsame identity
Upgrading the image

Before

  1. Note its node and ZeroTier addresses.
  2. Copy identity.public and identity.secret from the old folder to keep the identity.
  3. Make sure LAN or QuickConnect works.
  4. Stop and remove the old package; both cannot run.
Find the old files
find / -name identity.secret 2>/dev/null

Put them in the new folder and the container uses them: same device, same address.

What you should see

StepSee
tun.shNothing, and /dev/net/tun exists
docker runA long ID
docker psUp, not Restarting
zerotier-cli statusONLINE
join200 join OK
listnetworksOK and an address

Stop at the first difference.

Errors

permission denied … Docker daemon: sudo -i missing. operation not permitted: a --cap-add or --device missing. no such device tun: tun.sh did not run after the restart; check rights 755 and the first line. Safer: Control Panel → Task Scheduler → triggered at boot, user root.

DSM or SMB do not open

  • Firewall: allow the ZeroTier range.
  • Auto block: is the address in it.
  • QuickConnect names do not use ZeroTier.
  • SMB: \\zerotier-address\share.

Bring the whole home

Forwarding is lost at restart, so put it in the boot task:

Adapter as yours
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o eth0 -s 10.147.17.0/24 -j MASQUERADE
iptables -A FORWARD -i zt+ -j ACCEPT
iptables -A FORWARD -o zt+ -j ACCEPT

The NAS's own firewall may flush it; a router or Raspberry Pi does this with less care.

An old model without Docker?

DSM 6 can still use the old package; or run ZeroTier on a router or Raspberry Pi and reach the NAS through a gateway.

Slower in a container?

With host networking hardly; the NAS processor matters more.

With the graphical Container Manager?

Device and capabilities cannot all be set there; create by command, look there.

After a large DSM update?

tun.sh, the task, the container.

Other NAS?

The same idea: TUN, host network, two capabilities, a mounted folder.

Up next

Pages nearby

Marks: ZeroTier on Synology, DSM 7 ZeroTier, ZeroTier container Synology