Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save osakanataro/a9ba5ded340070b8e6abc28969d7ae4f to your computer and use it in GitHub Desktop.
Save osakanataro/a9ba5ded340070b8e6abc28969d7ae4f to your computer and use it in GitHub Desktop.
openWRTでV6プラス/BIGLOBEに接続するためのスクリプト
#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
@osakanataro
Copy link
Author

なるほど。その違いでしたか

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment