In this project, we will be showing you how to install and run ZeroTier on the Raspberry Pi.
ZeroTier is software that allows you to create virtual networks between your devices using a simple central web interface. You could compare these virtual networks to setting up a VPN on your Raspberry Pi. However, the provisioning experience is far simpler, especially when managing multiple devices.
Connections are made between each of your devices using a peer-to-peer network. These connections are secured using end-to-end encryption to help keep your data secure and private.
In addition to running ZeroTier on a Raspberry Pi, you can also run it on most other devices, including phones. Furthermore, it can work on Linux, Windows, and macOS, meaning you can create a virtual network without worrying whether your device can join.
ZeroTier runs on a freemium model. For the free plan we are using in this guide, you can have up to 50 authorized devices in your virtual network.
As a bonus, the ZeroTier team has made their code available on GitHub. One of the advantages of an open-source project is that you can see what the code is meant to be doing.
Below is a list of the equipment we used when running ZeroTier on the Raspberry Pi.
Retrieving your ZeroTier Network ID
To use the ZeroTier software on your Raspberry Pi, you must sign up to their website. The reason for this is that their website acts as the dashboard that controls the virtual network.
Using this web interface, you can control all aspects of your virtual network, with the ability to even set static IP addresses to specific devices.
1. To create a network ID, you will need to first sign up to the ZeroTier central web interface. This is the web interface that will allow you to create and manage virtual networks.
In your favorite web browser, go to the ZeroTier Central website. Once on the website, click the “
Register” link to begin creating your account.
2. On the register screen, fill out all the details you want to use for your ZeroTier account (1.).
Once you have filled out all of your information, click the “
Register” button at the bottom of the screen (2.).
After you have registered for an account, you will be required to verify the specified email address. You won’t be able to proceed until the email has been verified.
3. After registering your account and logging into the web interface, you will be greeted with the following screen.
All you need to do now is click the “
Create A Network” button in the middle of the screen.
4. Upon clicking the button, the ZeroTier website will immediately create your first network.
In this table, you can find the network ID. We will need this ID to connect your Raspberry Pi to this ZeroTier virtual network. Write down this ID as we will require this later on.
If you want to adjust details such as the network’s name, you need to click the entry.
5. Below is the basic settings that you can change for your ZeroTier network.
Using these settings, you can change the name of the network (1.), set a description (2.), or change the access control (3.).
ZeroTier also allows you to adjust several other aspects of the virtual network, such as the IP subnet.
Installing ZeroTier to the Raspberry Pi
Now that you have signed up to ZeroTier and retrieved a network ID, we can continue.
This section will show you how to install the ZeroTier software to your Raspberry Pi.
1. Before we start, let us make sure our Raspberry Pi is running up-to-date software.
We need to use the following two commands to update both the package list and any installed packages.
sudo apt update sudo apt upgrade
2. To install ZeroTier directly from their package repository to our Raspberry Pi, we will need to add the GPG key. This key helps verify the contents of the packages that we are installing are from ZeroTier.
Run the following command to download the GPG key from their GitHub repository, then pipe (
|) it directly to the APT key chain.
curl https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/doc/contact%40zerotier.com.gpg | sudo apt-key add -
3. With the GPG key added, we need to create a source list that contains the ZeroTier repository.
Before we do that, we must first store the codename for the current operating system in a shell variable called “
Running the following command will allow us to quickly build the correct URL for the ZeroTier repository in the next step.
4. We use the shell variable we set in the previous step to build the correct ZeroTier repository URL for your current operating system.
We then pipe this string into a file called “
zerotier.list” that is stored within the “
echo "deb http://download.zerotier.com/debian/$RELEASE $RELEASE main" | sudo tee /etc/apt/sources.list.d/zerotier.list
When you update your Raspberry Pi’s package list again, it will read from this repository to find ZeroTier.
5. As we have made changes to our Raspberry Pi’s sources, we need to update the package list.
You can update the package list by running the following command on your system
sudo apt update
6. Once we have performed an update, we can finally install the ZeroTier package to our Raspberry Pi using the command below.
sudo apt install -y zerotier-one
As a part of the installation process, ZeroTier will automatically enable itself to start at boot.
Running ZeroTier on the Raspberry Pi
Now that we have installed ZeroTier to our Raspberry Pi, we can connect it to the network we set up earlier in the guide.
Make sure that you have the ID of the network you want to connect to before continuing.
1. We will need to use the ZeroTier CLI to join the network on the Raspberry Pi.
To do this, you will need to use the following command. First, ensure that you replace “
[NETWORKID]” with the ID you got earlier in this guide.
sudo zerotier-cli join [NETWORKID]
If your Raspberry Pi successfully joins the ZeroTier network, you should see the following message.
200 join OK
2. Even though you have joined the ZeroTier network, you are required to authenticate your device before it becomes an actual member of the network.
To do this, you will need to return to the ZeroTier Central interface and select your network.
If you want, you can also go to the following URL, replacing “
[NETWORKID]” with your network ID.
3. Once you are on the management page for your Raspberry Pi’s ZeroTier network, you will need to scroll down to see the “
- Within this section, you will need to identify the device you added and click the “
This will allow your Raspberry Pi to connect with any other devices on the network.
- The “Address” column is what you can use to identify that particular device within your ZeroTier network.
You can get your Raspberry Pi to output this information by using the “
sudo zerotier-cli status” command.
- To make it easier to identify this new device in the future, you can use the Name/Description to give it a clear identifier.
- The last column that you will definitely want to look at is the “
Managed IPs” column.
This column will list any IPs that have been assigned to that particular device. You can use these IP addresses to connect to that particular device.
If you want to assign a particular IP address to a device, you can use this column.
Please note it may take a few moments before a newly authorized device will get assigned an IP address.
4. You can verify that your Raspberry Pi has now connected to the ZeroTier network by running the following command.
This command will list all networks that your ZeroTier installation is connected to and the status of that connection.
sudo zerotier-cli listnetworks
Below is an example of what you should see when your Raspberry Pi has successfully connected to your ZeroTier network. The last value is the IP address that was assigned to your Pi as a member of the virtual network.
200 listnetworks [Network ID] [Network NAME] [Network Address] OK PRIVATE [Virtual Name] [Virtual IP]
5. Your Raspberry Pi should now have successfully joined your ZeroTier network.
You will now be able to connect with any other devices that are a part of the virtual network. All you need to know is the IP address of that device.
The easiest place to find the IP addresses assigned to a device is through the ZeroTier central interface.
Remember that if you are using a firewall on your Raspberry Pi, such as UFW, you will still need to allow traffic from applications for the virtual network.
By this stage, you will now have successfully set up ZeroTier on your Raspberry Pi and connected to a virtual network.
ZeroTier is a straightforward virtual network solution that allows you to control everything through a simple web interface. Best of all, it has a great free plan that should be more than enough for most basic uses.
If you have had any issues getting ZeroTier running on your Pi, please leave a comment below.