文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>简单获取各大网络运营商IP段

简单获取各大网络运营商IP段

时间:2009-07-05  来源:zhaohang3031

      在许多情况下我们需要判断客户端的连接是电信还是网通,或者联通移动,那么,轻松获取客户端登录IP后如何判断究竟是哪个运营上的IP呢,下面脚本可以很轻易的帮您收集这些信息!   运行条件: 需要网络和 Internet 连通!    

#!/bin/sh

#auto get the IP Table

#get the newest delegated-apnic-latest

rm delegated-apnic-latest

if type wget
     then wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
     else fetch http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
fi
grep 'apnic|CN|ipv4' delegated-apnic-latest | cut -f 4,5 -d '|' | tr '|' ' ' | while read ip cnt
do
mask=$(bc <<END | tail -1
pow=32;
define log2(x) {
if (x<=1) return (pow);
pow--;
return(log2(x/2));
}
log2($cnt);
END
)
echo $ip/$mask';'>>cnnet

resultext=`whois [email protected] | grep -e ^netname -e ^descr -e ^role -e ^mnt-by | cut -f 2 -d ':' | sed 's/ *//'`

if echo $resultext | grep -i -e 'railcom' -e 'crtc' -e 'railway'
    then echo $ip/$mask';' >> crc
elif echo $resultext | grep -i -e 'cncgroup' -e 'netcom'
    then echo $ip/$mask';' >> cnc
fi
if echo $resultext | grep -i -e 'chinanet' -e 'chinatel'
    then echo $ip/$mask';' >> telcom_acl
elif echo $resultext | grep -i -e 'unicom'
    then echo $ip/$mask';' >> unicom
elif echo $resultext | grep -i -e 'cmnet'
    then echo $ip/$mask';' >> cmnet
else
    echo $ip/$mask';' >> other_acl
fi
done

 

 

相关阅读 更多 +
排行榜 更多 +
罗马战争与防御

罗马战争与防御

策略塔防 下载
3d坦克突击最新版

3d坦克突击最新版

飞行射击 下载
3d子弹先生射击模拟器安卓版

3d子弹先生射击模拟器安卓版

飞行射击 下载