從apnic提取ip信息腳本分享
#!/bin/bash
# download from apnic
rm -f delegated-apnic-latest
wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
# IPs allocated to china.
grep 'apnic|CN|ipv4|' delegated-apnic-latest | cut -f 4 -d'|' > delegated-apnic-CN
# get detail of echo IP from apnic database.
rm -f apnic_CN.txt
while read ip
do
# query apnic database
echo "query who is $ip"
whois -h whois.apnic.net $ip > tmp.txt
grep inetnum tmp.txt >> apnic_CN.txt # IP range
grep netname tmp.txt >> apnic_CN.txt # netname which include sp information
grep descr tmp.txt >> apnic_CN.txt # description which include province information
echo "" >> apnic_CN.txt
done < delegated-apnic-CN
# clean up
rm -f tmp.txt
rm -f delegated-apnic-latest
rm -f delegated-apnic-CN
相關(guān)文章
關(guān)于Linux反空閑設(shè)置的兩種方法總結(jié)
下面小編就為大家?guī)硪黄P(guān)于Linux反空閑設(shè)置的兩種方法總結(jié)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03linux定時任務(wù)出現(xiàn)command not found解決辦法
這篇文章主要介紹了 linux定時任務(wù)出現(xiàn)command not found解決辦法的相關(guān)資料,需要的朋友可以參考下2017-05-05bash腳本如何監(jiān)控cup/內(nèi)存/磁盤使用率
本文主要介紹了bash腳本如何監(jiān)控cup/內(nèi)存/磁盤使用率,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-10-10