本帖最后由 zflczx 于 2011-10-28 14:52 编辑
原文请访问:http://m114.org
APNIC是管理亚太地区IP地址分配的机构,它有着丰富准确的IP地址分配库,同时这些信息也是对外公开的!
在Linux下获得一些国内运营商的IP地址段的情况:
1、编译安装软件 - shell> wget http://ftp.apnic.net/apnic/dbase/tools/ripe-dbase-client-v3.tar.gz
- shell> tar xzvf ripe-dbase-client-v3.tar.gz
- shell> cd whois-3.1
- shell> ./configure
- shell> make && make install
复制代码
2、获取IP并转换为智能DNS格式
- #!/bin/bash
- # date: 2011-10-28
- # Author: vinson
- # Blog: http://m114.org
- #获取网通IP
- whois3 -h whois.apnic.net -l -i mb MAINT-CNCGROUP |grep "descr" |grep "Reverse" | awk -F "for" '{if($2!="") print$2}' |sort -n | awk 'BEGIN{print "acl \"CNC\" '{'"}{print $1";"}END{print "'}';"}' > cnc_acl.conf
- #获取电信IP
- whois3 -h whois.apnic.net -l -i mb MAINT-CHINANET |grep "descr" |grep "Reverse" | awk -F "for" '{if($2!="") print$2}' |sort -n | awk 'BEGIN{print "acl \"CTC\" '{'"}{print $1";"}END{print "'}';"}' > ctc_acl.conf
- #获取铁通IP
- whois3 -h whois.apnic.net -l -i mb MAINT-CN-CRTC |grep "inetnum" |sed 's/inetnum: //g' |sort -n |
- awk -F'[.-]' '
- {
- print $1"."$2"."$3"."$4,(255-($(NF-3)-$1))"."(255-($(NF-2)-$2))"."(255-($(NF-1)-$3))"."(255-($NF-$4))
- }' |
- while read ip mask
- do
- a=$(ipcalc -p $ip $mask |awk -F= '{print$2}')
- echo $ip/$a >>temp
- done
- more temp |awk 'BEGIN{print "acl \"CRTC\" '{'"}{print $1";"}END{print "'}';"}' > crtc_acl.conf
- rm -f temp
复制代码
下载:
脚本
电信
网通
铁通
参考:
http://blog.csdn.net/east271536394/article/details/6402475
http://hi.baidu.com/leejun_2005/blog/item/5ff74c3fa4b2f22971cf6cd5.html
http://hi.baidu.com/dmkj2008/blog/item/98a23850ae939d531038c28b.html
|