Set Up a ZeroTier Network on OpenWRT
Presentation
In this test, we set up Zerotier on GL.iNet’s mini-routers and an Ubuntu VPS so that they can access each other. To use ZeroTier service, you need to create your own ZeroTier account. Sign up for an account here: https://my.zerotier.com/login.
Important: Stop other VPN service on the router before you start is recommended
Login your ZeroTier account. Go to Network menu and click on Create button
to create a new network.
Next you should see the configuration page of your network. Please jot down the Network ID which will be used later.
Setup ZeroTier on router
Installation
SSH to the router, and execute the following commands to install ZeroTier package:
1 | opkg update |
Configuration
ZeroTier
You should edit the configuration file /etc/config/zerotier to enable ZeroTier
and join into a network. It looks like:
1 | # cat /etc/config/zerotier |
Please replace the code above d5e5fb6537869a7d with your own Network ID.
Firewall(optional)
If you want to access the router’s LAN, you have to configure the firewall as
well. Please edit the firewall configuration file /etc/config/firewall. Add
below lines into it.
1 | config zone 'vpn_zone' |
Start ZeroTier Service
1 | /etc/init.d/zerotier restart |
Go back to your Zerotier’s web console and you will see the device which you just joined. Check the checkbox of “Auth?”, otherwise, your device may not be able to get an IP address from ZeroTier.
After authentication, the network interface will obtain an IP address. Check it
out via ifconfig
, it looks like:
1 | # ifconfig |
Managed Routes(optional)
You can manage route in ZeroTier’s web console. For example, I add a static route on Managed Routes, so that I can access the router’s LAN.
Setup ZeroTier on Ubuntu
Installation
Install ZeroTier and join the network which you created before.
1 | curl -s https://install.zerotier.com/ | sudo bash |
Please replace the code above d5e5fb6537869a7d with your own Network ID.
You need to check the checkbox of “Auth?” in ZeroTier’s web console as well.
After authentication, the network interface will obtain an IP address. Check it
out via ifconfig
, it looks like:
1 | # ifconfig |
Testing
The router and the Ubuntu VPS are able to ping each other.
1 | kyson@ip-172-31-34-95:~$ ping 10.241.143.3 |
1 | root@GL-AR300M:/# ping 10.241.116.0 |
The Ubuntu VPS can reach router’s LAN if you configure the route.
1 | kyson@ip-172-31-34-95:~$ ping 192.168.8.1 |
Troubleshooting
If everthing is fine, but you can’t reach the router from Ubuntu VPS. It usually caused by mwan3, you can try to stop and remove it.
1 | mwan3 stop |