Site Tools


freshtomato_zerotier

This is an old revision of the document!


Connecting FreshTomato to Zerotier

ZeroTier lets you build modern, secure, multi-point virtualized networks of almost any type. From robust peer-to-peer networking to multi-cloud mesh infrastructure, you can achieve global connectivity with the ease and simplicity of a local LAN.

1. Register an account on the Zerotier official website

2. Create a network on ZeroTier Central, note down the network ID

3. Use Entware to install Zerotier (“opkg install zerotier”) on your router.

If your router is MIPS-based, the Zerotier version may be very old (~1.1.4), and if so, can't use some functions such as 'join orbit'. You can download the newest version from: ZeroTierOne 1.10.6 mipsel static-bin, and replace the old version.

4. Use this script to control zerotier (auto start zerotierone daemon and join the network, stop and unload tun etc..), remember replace your own NETWORK_ID in the script:

#!/bin/sh
 
 
PREFIX="/opt/bin"
NAME="zerotier-one"
CTL_NAME="zerotier-cli"
FRIENDLY="ZeroTier ONE"
NETWORK_ID="e4da3344b2c13e80"
WORKING_DIR="/opt/var/lib/zerotier-one"
CMDLINE="-d $WORKING_DIR"
LOG_FILE="/var/log/${NAME}.log"
 
 
alias elog="logger -t $NAME -s"
 
 
COND=$1
[ $# -eq 0 ] && COND="start"
 
 
start() {
    if [ -n "$(pidof $NAME)" ]; then
        elog "$FRIENDLY is already running."
        exit 1
    fi
    elog "Starting $FRIENDLY Services: "
    lsmod | grep -q "tun" || modprobe tun
    $PREFIX/$NAME $CMDLINE
    sleep 5
    $PREFIX/$CTL_NAME join ${NETWORK_ID}
    if [ "$?" = "0" ]; then
        elog "succeeded."
    else
        elog "failed."
    fi
}
 
 
stop() {
    if [ ! -n "$(pidof $NAME)" ]; then
        elog "$FRIENDLY is not running."
    fi
    elog "Shutting down $FRIENDLY Services: "
    killall -SIGTERM "$NAME"
    sleep 5
    lsmod | grep -q "tun" && modprobe -r tun
    if [ "$?" = "0" ]; then
        elog "succeeded."
    else
        elog "failed."
    fi
}
 
 
do_info() {
    elog "Starting $FRIENDLY Services info mode: "
    $PREFIX/$CTL_NAME info
}
 
 
do_restart() {
    stop
    sleep 3
    start
}
 
 
case "$COND" in
start)
    start
    ;;
stop)
    stop
    ;;
restart)
    do_restart
    ;;
info)
    do_info
    ;;
*)
    elog "Usage: $0 (start|stop|restart|info)"
    ;;
esac
exit 0
  • 5. When zerotier run and join network success, go ZeroTier Central authorized the new device(this router), all done.
  • 6. Check the ZeroTier Knowledge Base for more info about zerotier.
freshtomato_zerotier.1682193531.txt.gz · Last modified: 2023/04/22 20:58 by hogwild