Shell腳本獲取國內(nèi)各大運(yùn)營商網(wǎng)段腳本分享
亞太地區(qū)網(wǎng)絡(luò)信息記錄在這里,每天都有更新。
http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
下面這個(gè)腳本將對這段文本進(jìn)行編輯,輸出國內(nèi)幾大運(yùn)營商網(wǎng)段。
#!/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
elif 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)文章
Shell之function函數(shù)的定義及調(diào)用示例
本文主要介紹了Shell之function函數(shù)的定義及調(diào)用示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08關(guān)于shell的幾個(gè)不為人知卻十分有用的命令分享
這篇文章主要介紹了關(guān)于shell的幾個(gè)不為人知卻十分有用的命令,需要的朋友可以參考下2016-03-03svn服務(wù)器啟動(dòng)和svn服務(wù)器重啟、停止等操作腳本分享
這篇文章主要介紹了svn服務(wù)器啟動(dòng)和svn服務(wù)器重啟、停止等操作腳本,需要的朋友可以參考下2014-03-03一個(gè)簡單的轉(zhuǎn)換輸出的shell腳本代碼
一個(gè)簡單的轉(zhuǎn)換輸出的shell腳本,學(xué)習(xí)shell腳本的朋友可以看下實(shí)現(xiàn)方法2013-02-02Linux Shell+Curl網(wǎng)站健康狀態(tài)檢查腳本,抓出中國博客聯(lián)盟失聯(lián)站點(diǎn)
這篇文章主要介紹了Shell+Curl網(wǎng)站健康狀態(tài)檢查腳本,抓出中國博客聯(lián)盟失聯(lián)站點(diǎn),需要的朋友可以參考下2016-02-02