1.i wrote a script and put under /etc/ppp/ip-up.d, but the system doesn't run the script when the ppp0 is up.
2.i did chmod a+x
3.the script:
var1=`ifconfig ppp0 | grep 'addr:' | sed 's/.*addr:\([^ ]\{2,3\}\).*/\1/'`
if [ "$var1" != 218 ]; then
ifdown wan && ifup wan
else
WANIP=$(ifconfig ppp0 | grep addr | awk '{print $2}' | sed 's/addr://')
iptables -t nat -A prerouting_rule -d $WANIP -p tcp -j DNAT --to 192.168.1.100
iptables -A forwarding_rule -p tcp -d 192.168.1.100 -j ACCEPT
iptables -t nat -A postrouting_rule -s 192.168.0.0/12 -p tcp -d 192.168.1.100 -j MASQUERADE
fi
3.1.the purpose of the script: Keep reconnect until get a wan IP start with 218 (218.x.x.x), if the IP is start with 218 then it'll create a loopback firewall rule.
