由於寫教學太花時間了我就直接把需要的指令放到下面
# Upgrade and update the apt
sudo apt-get upgrade
sudo apt-get update
# Install Git (if you didn't install it yet)
sudo apt-get install git
#Install Make and build dependencies
sudo apt-get install make
sudo apt-get install build-essential
# Clone the source code of the zeroTier client
cd ~/
mkdir build
cd ./build
git clone https://github.com/zerotier/ZeroTierOne
# Optional: Install screen and run it inside screen so you can disconnect your ssh terminal
sudo apt-get install screen -y
screen
# Start building the ZeroTier Client
cd ./ZeroTierOne
make
# Optional: If you have screen installed
(Hold Ctrl A + D to detach the terminal)
然後你就可以去吃個飯再回來了。這 Make 在 Intel 處理器的電腦上也行有夠久的,如果是 Rpi 之類的 SBC 就更不用想它會快了。
在它完成建置之後,你應該會看到類似這樣的檔案結構,如果 OK 的話就可以繼續:
# Join your network using Network ID
sudo ./zerotier-cli join <networkID>
# Test if the compilation is working and setup the network
sudo zerotier-one -d
前往 ZeroTier 的網站,幫新出現的裝置改名和設成 Auth
等一下之後他會顯示 DHCP 派發給這台裝置的 IP 地址,而回去 Linux 上面你使用 ifconfig 應該能看到相同的地址
如果是正確的話可以繼續:
# Create a start script for the zerotier daemon
sudo nano ~/zerotier.sh
把下面的資料放進去然後 Save + Exit (把 <user_name> 改成你現在在用的使用者名稱)
#!/bin/sh
sudo /home/<user_name>/build/ZeroTierOne/zerotier-one
# Add zeroTier to systemctl to start on boot
sudo nano /etc/systemd/system/zerotier.service
把下面的資料放進去 zerotier.service,然後 Save + Exit
[Unit]
Description=ZeroTier Network Manager
[Install]
WantedBy=multi-user.target
[Service]
ExecStart=/bin/bash /home/aroz/zerotier.sh
Type=simple
# Enable the service
sudo systemctl enable zerotier.service
sudo systemctl start zerotier.service
# Reboot and see if new network pop up afterward
sudo reboot
#Wait until reboot finish
sudo ifconfig
#You should see the zeroTier network popup in the list