To install ZeroTier, one would typically allow port 9993/UDP on their firewall. However, in certain scenarios, you may need to run a ZeroTier moon on non-standard ports due to network restrictions (e.g. behind NAT) or conflicts with other services. This guide will walk you through the steps to set up a ZeroTier moon on non-standard ports.
Setup Relays (Moon Nodes) on Non-Standard Ports
Install ZeroTier like usual:
| |
Setup moon:
| |
Here is the important part: edit the moon.json file to specify the desired non-standard ports. Open the file with your preferred text editor:
| |
Modify the stableEndpoints section to include your public IP address along with the desired non-standard port. If you are behind a NAT, use your router’s public IP address and forward the same port from your server to your router. The format should be IP_ADDRESS/PORT.
For example, if you want to use port 14999, change the line to:
| |
Generate the moon configuration (this is what clients will use to connect to your moon):
| |
You should have one file that looks like *.moon in your current dir. Move the generated moon file to the ZeroTier directory:
| |
If your moon also acts as a client, change the client configuration to use the non-standard port. Edit /var/lib/zerotier-one/local.conf:
| |
Restart the ZeroTier service to apply the changes:
| |
Setup Clients (Leaf Nodes)
On the client side, you have to change the default port as well. Yes, the client’s default port (9993) must match the moon’s port. Otherwise, they won’t be able to communicate in my tests.
After you installed ZeroTier and joined the network, edit /var/lib/zerotier-one/local.conf:
| |
Copy /var/lib/zerotier-one/moons.d/*.moon from the moon server to the client machine’s /var/lib/zerotier-one/moons.d/ directory, so the client knows about the moon:
| |
Restart the ZeroTier service on the client:
| |
Verification
You can verify that the moon is functioning correctly by checking zerotier-cli command on the client to see if it can connect to the moon.
| |
You should see an entry for your moon with the correct non-standard port, similar to the example below (xxx.xxx.xxx.xxx/14999):
| |
If your <lat> is -1, it means the client cannot reach the moon. Double-check your configuration and ensure that the specified ports are open and correctly forwarded if behind a NAT.