[转载]从apnic获取电信 网通 铁通等ip的办法(整理)
信息来源:邪恶八进制信息安全团队([url]www.eviloctal.com[/url])APNIC是管理亚太地区IP地址分配的机构,它有着丰富准确的IP地址分配库,同时这些信息也是对外公开的!下面就让我们看看如何在Linux下获得一些电信运营商的IP地址分配情况:
shell> wget [url]http://ftp.apnic.net/apnic/dbase/tools/ripe-dbase-client-v3.tar.gz[/url]
shell> tar xzvf ripe-dbase-client-v3.tar.gz
shell> cd whois-3.1
shell> ./configure
shell> make
完成上述编译安装工作后,我们开始获取IP地址段;
中国网通:shell> ./whois3 -h whois.apnic.net -l -i mb MAINT-CNCGROUP > /var/cnc
中国电信:shell> ./whois3 -h whois.apnic.net -l -i mb MAINT-CHINANET > /var/chinanet
中国铁通:shell> ./whois3 -h whois.apnic.net -l -i mb MAINT-CN-CRTC > /var/crtc
打开获取后的文件可以看到里面的信息非常详细,甚至可以看到各个分公司的负责人、电话、电子邮件等等信息。如果想得到一份整齐干净的IP地址段文件,只要用grep和awk简单过滤就可以了:)
__________________________________________________________________
使用ripe-whois3获得电信,网通等运营商的ip地址
Linux中下载安装
[url]http://ftp.apnic.net/apnic/dbase/tools/ripe-whois-tools-2.3.tar.gz[/url]
tar xzvf ripe-whois-tools-2.3.tar.gz
cd /usr/ports/net/ripe-whois3
make install clean
rehash
查询:
中国网通: whois3 -h whois.apnic.net -l -i mb MAINT-CNCGROUP
中国电信: whois3 -h whois.apnic.net -l -i mb MAINT-CHINANET
中国铁头: whois3 -h whois.apnic.net -l -i mb MAINT-CNC-CRTC grep 'CN|ipv4' delegated-apnic-latest | cut -f 4,5 -d '|' | tr '|' ' ' > cnnet
#!/bin/sh
cat cnnet | 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
)
resultext=`whois -A $ip | grep -e ^netname -e ^descr -e ^mnt | cut -f 2 -d ':' | sed 's/ *//'`
echo '----------------------------------------------'
echo $resultext
echo "" >> LOGFILE
echo "" >> LOGFILE
echo "" >> LOGFILE
echo $resultext >> LOGFILE
echo '..............................................'
#if echo $resultext | grep -i -e 'chinanet' -e 'chinatel'
#then echo $ip/$mask >> CHINANET
#fi
#if echo $resultext | grep -i -e 'unicom'
#then echo $ip/$mask >> UNICOM
#fi
if echo $resultext | grep 'CNC'
then echo $ip/$mask >> CNC
fi
echo '----------------------------------------------'
echo ''
done
页:
[1]