Created
May 17, 2021 14:32
-
-
Save osakanataro/a9ba5ded340070b8e6abc28969d7ae4f to your computer and use it in GitHub Desktop.
openWRTでV6プラス/BIGLOBEに接続するためのスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#units=63 | |
units=15 | |
IP4='xxx.xxx.xxx.xxx' | |
#PSID='6e' | |
#PSID='110' | |
PSID=110 | |
LANDEV='br-lan' | |
WAN6DEV='eth0' | |
TUNDEV='map-MAP' | |
iptables -t nat -F PREROUTING | |
iptables -t nat -F OUTPUT | |
iptables -t nat -F POSTROUTING | |
rule=1 | |
while [ $rule -le $units ] ; do | |
mark=`expr $rule + 16` | |
pn=`expr $rule - 1` | |
portl=`expr $rule \* 4096 + $PSID \* 16` | |
portr=`expr $portl + 15` | |
echo iptables -t nat -A PREROUTING -p tcp -m statistic --mode nth --every $units --packet $pn -j MARK --set-mark $mark | |
iptables -t nat -A PREROUTING -p tcp -m statistic --mode nth --every $units --packet $pn -j MARK --set-mark $mark | |
echo iptables -t nat -A OUTPUT -p tcp -m statistic --mode nth --every $units --packet $pn -j MARK --set-mark $mark | |
iptables -t nat -A OUTPUT -p tcp -m statistic --mode nth --every $units --packet $pn -j MARK --set-mark $mark | |
echo iptables -t nat -A POSTROUTING -p icmp -m connlimit --connlimit-daddr --connlimit-upto 16 --connlimit-mask 0 -o $TUNDEV -j SNAT --to $IP4:$portl-$portr | |
iptables -t nat -A POSTROUTING -p icmp -m connlimit --connlimit-daddr --connlimit-upto 16 --connlimit-mask 0 -o $TUNDEV -j SNAT --to $IP4:$portl-$portr | |
echo iptables -t nat -A POSTROUTING -p tcp -o $TUNDEV -m mark --mark $mark -j SNAT --to $IP4:$portl-$portr | |
iptables -t nat -A POSTROUTING -p tcp -o $TUNDEV -m mark --mark $mark -j SNAT --to $IP4:$portl-$portr | |
echo iptables -t nat -A POSTROUTING -p udp -m connlimit --connlimit-daddr --connlimit-upto 16 --connlimit-mask 0 -o $TUNDEV -j SNAT --to $IP4:$portl-$portr | |
iptables -t nat -A POSTROUTING -p udp -m connlimit --connlimit-daddr --connlimit-upto 16 --connlimit-mask 0 -o $TUNDEV -j SNAT --to $IP4:$portl-$portr | |
rule=`expr $rule + 1` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なるほど。その違いでしたか