Posted on 2008-02-11 18:36
小蚂蚁 阅读(782)
评论(1) 编辑 收藏 所属分类:
FreeBSD
花生壳的IP地址和实际公网的地址不一致问题一直没得到解决,询问客服也没有解决的办法,通过观察,我发现不是每次拨号都会出现IP不一致的情况,说明我的ISP只在一定范围内安装了NAT转发的设备,自己写了个脚本,比较花生壳和wan ip,如果不一致,就从新拨号分配一个新IP,运行了半个月,效果蛮好,可惜了我花100元升级专业用户.
--------------------------------
#!/bin
# wan.sh
#get wan ip from TP-LINK route
wanip=`wget --user=admin --password=admin -q -O - http://192.168.2.1/userRpm/StatusRpm.htm |\
grep "00-50-FC-77-C9-06" |\
awk -F, '{print $3}' | tr -d ' "'`
echo "$wanip"
----------------------------------------------
#!/bin/sh
# fixip.sh
#fix vicp ip
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/phlinux"
disUrl='http://192.168.2.1/userRpm/StatusRpm.htm?Disconnect=断%20开&wan=1'
conUrl='http://192.168.2.1/userRpm/StatusRpm.htm?Connect=连%20接&wan=1'
wg='wget -q --user=admin --password=admin -O - '
c=0
while [ "$c" -lt "5" ]
do
wip=`wan.sh`
vicp=`nslookup myhome.vicp.net | tail -n2 | grep "Address" | awk '{print $2}'`
if [ "$wip" == "$vicp" ]; then
echo "Match done."
exit 0
fi
echo "my wan ip : "$wip
echo "myhome.vicp.net : "$vicp
echo "Fix ip ..."
if [ -n wip ]; then
echo " disconnect PPPoe ..."
`$wg $disUrl > /dev/null`
sleep 3
fi
echo " connect PPPoE ..."
`$wg $conUrl > /dev/null`
sleep 37
c=`expr $c + 1`
done