欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

輕松獲得網(wǎng)通、電信、鐵通IP地址分配段的方法

 更新時(shí)間:2007年11月09日 20:11:57   作者:  
有時(shí)搞一些跨網(wǎng)段的工程和應(yīng)用,需要盡量準(zhǔn)確的知道電信、網(wǎng)通、鐵通等電信運(yùn)營商的IP地址段分配情況,可網(wǎng)上的資料不但很少,而且經(jīng)常都是N個(gè)月前的過期資料……
APNIC是管理亞太地區(qū)IP地址分配的機(jī)構(gòu),它有著豐富準(zhǔn)確的IP地址分配庫,同時(shí)這些信息也是對(duì)外公開的!下面就讓我們看看如何在Linux下獲得一些電信運(yùn)營商的IP地址分配情況:
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
完成上述編譯安裝工作后,我們開始獲取IP地址段;
中國網(wǎng)通:
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
打開獲取后的文件可以看到里面的信息非常詳細(xì),甚至可以看到各個(gè)分公司的負(fù)責(zé)人、電話、電子郵件等等信息。如果想得到一份整齊干凈的IP地址段文件,只要用grep和awk簡單過濾就可以了:)

一個(gè)轉(zhuǎn)自CU的自動(dòng)獲取腳本 :
復(fù)制代碼 代碼如下:

#!/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 $ip@whois.apnic.net | 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    
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 

相關(guān)文章

最新評(píng)論