首页 > 编程知识 正文

从 APNIC 提取IP地址信息,照片怎么看地址信息

时间:2023-05-06 21:13:15 阅读:218742 作者:637

操作系统:ubuntu14 桌面版

工具:Whois3
下载 whois3

wget ftp://ftp.apnic.net/apnic/dbase/tools/ripe-dbase-client-v3.tar.gz

安装 whois3

tar zxvf ripe-dbase-client-v3.tar.gz cd whois-3.1/# 这里使用默认参数即可./configuresudo make && sudo make install

获取IP地址信息

将如下代码保存为 getip.sh 的 shell 脚本

#!/wmdsh/bash# download from apnicrm -f delegated-apnic-latestwget 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.txtwhile read ipdo # query apnic database echo "query who is $ip" whois3 -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 uprm -f tmp.txtrm -f delegated-apnic-latestrm -f delegated-apnic-CN

赋予该脚本可执行权限

chmod +x getip.sh

然后执行该脚本
./getip.sh

如果执行成功,则会生成一个 apnic_CN.txt 文件
里面包含了如下形式的数据

inetnum: 1.0.1.0 - 1.0.1.255netname: CHINANET-FJdescr: CHINANET FUJIAN PROVINCE NETWORKdescr: China Telecomdescr: No.31,jingrong streetdescr: Beijing 100032

脚本参考 http://www.jb51.net/article/47664.htm 整理

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。