mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-15 03:51:51 +00:00
28 lines
705 B
Bash
Executable file
28 lines
705 B
Bash
Executable file
#!/bin/sh
|
|
|
|
zero_enable="$(uci get zerotier.sample_config.enabled)"
|
|
|
|
[ "${zero_enable}" -ne "1" ] && exit 0
|
|
|
|
[ -f "/tmp/zero.log" ] && {
|
|
while [ "$(ifconfig | grep 'zt' | awk '{print $1}')" = "" ]
|
|
do
|
|
sleep 1
|
|
done
|
|
}
|
|
|
|
nat_enable="$(uci get zerotier.sample_config.nat)"
|
|
zt0="$(ifconfig | grep 'zt' | awk '{print $1}')"
|
|
echo "${zt0}" > "/tmp/zt.nif"
|
|
|
|
[ "${nat_enable}" -eq "1" ] && {
|
|
for i in ${zt0}
|
|
do
|
|
ip_segment=""
|
|
iptables -I FORWARD -i "$i" -j ACCEPT
|
|
iptables -I FORWARD -o "$i" -j ACCEPT
|
|
iptables -t nat -I POSTROUTING -o "$i" -j MASQUERADE
|
|
ip_segment="$(ip route | grep "dev $i proto kernel" | awk '{print $1}')"
|
|
iptables -t nat -I POSTROUTING -s "${ip_segment}" -j MASQUERADE
|
|
done
|
|
}
|