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, we need to install Rust and Cargo, the package manager and build tool for Rust. We’ll follow the official installation instructions from rustup.rs (https://rustup.rs/) to ensure we’re using the recommended method 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"
Next, we need to enable the TUN module, which is 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, we can proceed by cloning the ZeroTier One source code from GitHub (https://github.com/zerotier/ZeroTierOne). Afterward, compile and install the application using make, which will handle the building and installation process for you.
alpine:~# git clone https://github.com/zerotier/ZeroTierOne.git alpine:~# cd ZeroTierOne alpine:~# make alpine:~# make install
Now, it’s time to configure OpenRC to ensure that 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 Return, and exit the editor using Ctrl + X.
alpine:~# nano /etc/init.d/zerotier-one #!/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
At this point, we need to adjust the access rights for the ZeroTier service and set it as the default service to start at boot. This step ensures the application runs as expected every time your system starts.
alpine:~# chmod +x /etc/init.d/zerotier-one alpine:~# rc-update add zerotier-one default alpine:~# rc-service zerotier-one start
Finally, run the provided commands to confirm that the ZeroTier service has been installed and configured correctly. This check will ensure everything is set up properly and the service is ready to use.
alpine:~# chmod +x /etc/init.d/zerotier-one alpine:~# rc-service zerotier-one status * status: started alpine:~# zerotier-cli status 200 info ab1234c567 1.14.2 ONLINE
I hope you appreciated this extensive guide on how to get ZeroTier One set up on Alpine Linux. Feel free to buy me a coffee.