the.nerdy.talk

Crafting Bytes for Better Lives

Compile ZeroTier One on Alpine Linux from GitHub Source

Published on 1/3/2025

Compile ZeroTier One on Alpine Linux from GitHub Source

ZeroTier One is a versatile, open-source software-defined networking (SDN) platform that allows you to create secure and private virtual networks over the internet. It’s widely used for connecting devices across diverse locations as if they were on the same local network, enabling seamless remote access, IoT device management, and advanced networking configurations. However, official APK packages for Alpine Linux are no longer maintained, leaving users to compile it from source. Despite this, ZeroTier remains a desirable choice for its powerful capabilities and ease of use once installed. This guide will walk you through the process of compiling ZeroTier One from scratch on Alpine Linux, ensuring that even without official packages, you can still leverage its networking power.

Prerequisites for ZeroTier One Guide

To successfully follow this guide, ensure you have the following:

  • Alpine Linux installation with root access (e.g., alpine-virt-3.21.0-aarch64)

System Preparation of Alpine Linux

Start by updating your package manager and installing the necessary dependencies to compile ZeroTier One on Alpine Linux. This ensures your system is equipped with the tools required for the next steps.

alpine:~# apk update
alpine:~# apk add git make gcc g++ linux-headers openssl-dev nano

Next, install Rust and Cargo, the package manager and build tool for Rust. Use the official installation instructions from rustup.rs (https://rustup.rs) for a clean setup:

alpine:~# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Select 1) Proceed with standard installation (default - just press enter)
alpine:~# . "$HOME/.cargo/env"

Enable the TUN module, essential for networking to function properly with ZeroTier One. This step ensures that the virtual network interfaces are correctly managed:

alpine:~# modprobe tun
alpine:~# lsmod | grep tun
tun                    57344  0
alpine:~# echo "tun" | tee -a /etc/modules
tun

Compiling ZeroTier One from GitHub Source

Once the environment is set up, clone the ZeroTier One source code from GitHub (https://github.com/zerotier/ZeroTierOne) and compile it:

alpine:~# git clone https://github.com/zerotier/ZeroTierOne.git
alpine:~# cd ZeroTierOne
alpine:~# make
alpine:~# make install

Configure OpenRC to ensure ZeroTier One starts automatically on boot. Open the configuration file with the nano editor, add the required script, save the changes with Ctrl + O followed by Enter, and exit the editor using Ctrl + X:

alpine:~# nano /etc/init.d/zerotier-one

Insert the following script into the file:

#!/sbin/openrc-run

depend() {
    after network-online
    want cgroups
}

supervisor=supervise-daemon
name=zerotier-one
command="/usr/sbin/zerotier-one"
command_args=" >>/var/log/zerotier-one.log 2>&1"

output_log=/var/log/zerotier-one.log
error_log=/var/log/zerotier-one.log

pidfile="/var/run/zerotier-one.pid"
respawn_delay=5
respawn_max=0

Adjust the access rights for the ZeroTier service and set it as the default service to start at boot:

alpine:~# chmod +x /etc/init.d/zerotier-one
alpine:~# rc-update add zerotier-one default
alpine:~# service zerotier-one start

Final Thoughts

By following this guide, you can successfully compile and install ZeroTier One on Alpine Linux, despite the lack of official APK packages. This enables you to leverage the full power of ZeroTier's SDN capabilities for secure and flexible networking.

Last built: December 24, 2024
Built with SvelteKit + Tailwind