安装
curl -s 'https://pgp.mit.edu/pks/lookup?op=get&search=0x1657198823E52A61' | gpg --import && \
if z=$(curl -s 'https://install.zerotier.com/' | gpg); then echo "$z" | sudo bash; fi
curl -s https://install.zerotier.com/ | sudo bash
sudo su
zerotier-cli join <网络ID>
# 开启路由转发
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p
# 808557a394 为zerotier给树莓派分配的id,可以通过 zerotier-cli status查看
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o 808557a394 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i 808557a394 -o eth0 -j ACCEPT
# iptables -t nat -A POSTROUTING -s 10.10.10.0/24 -j MASQUERADE
zerotier后台配置
10.243.51.160是树莓派分配的zerotier ip
image.png
测试
在另一台服务上ping 树莓派局域网内其他设备ip地址
网友评论