乐趣区

关于ip:从APNIC获取中国IP地址列表

对于 APNIC

    寰球 IP 地址块被 IANA(Internet Assigned Numbers Authority) 调配给寰球三大地区性 IP 地址调配机构,它们别离是:

ARIN (American Registry for Internet Numbers)

    负责北美、南美、加勒比以及非洲撒哈啦局部的 IP 地址调配。同时还要给寰球 NSP(Network Service Providers) 调配地址。

RIPE (Reseaux IP Europeens)

    负责欧洲、中东、北非、西亚局部地区 (前苏联)

APNIC (Asia Pacific Network Information Center)

    负责亚洲、太平洋地区

APNIC IP 地址调配信息总表的获取:

APNIC 提供了每日更新的亚太地区 IPv4,IPv6,AS 号调配的信息表:http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
 该文件的格局与具体内容参见:ftp://ftp.apnic.net/pub/apnic/stats/apnic/README.TXT

通过该文件咱们可能失去 APNIC 辖下 IPv4 地址空间的分配情况。

脚本获取 IP 地址

#!/bin/bash
wget -c http://ftp.apnic.net/stats/apnic/delegated-apnic-latest

cat delegated-apnic-latest | awk -F '|' '/CN/&&/ipv4/ {print $4"/"32-log($5)/log(2)}' | cat > ipv4.txt

cat delegated-apnic-latest | awk -F '|' '/CN/&&/ipv6/ {print $4"/"32-log($5)/log(2)}' | cat > ipv6.txt

cat delegated-apnic-latest | awk -F '|' '/HK/&&/ipv4/ {print $4"/"32-log($5)/log(2)}' | cat > ipv4-hk.txt

cat delegated-apnic-latest | awk -F '|' '/HK/&&/ipv6/ {print $4"/"32-log($5)/log(2)}' | cat > ipv6-hk.txt

执行脚本:

[root@cby cby]# ./ip.sh 
--2021-04-29 12:17:13--  http://ftp.apnic.net/stats/apnic/delegated-apnic-latest
Resolving ftp.apnic.net (ftp.apnic.net)... 203.119.102.40, 2001:dd8:8:701::40
Connecting to ftp.apnic.net (ftp.apnic.net)|203.119.102.40|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3352151 (3.2M) 
Saving to:‘delegated-apnic-latest’delegated-apnic-latest            100%[=============================================================>]   3.20M  61.3KB/s    in 44s     

2021-04-29 12:17:58 (74.0 KB/s) -‘delegated-apnic-latest’saved [3352151/3352151]
[root@cby cby]# ls
delegated-apnic-latest  index.html  ip.sh  ipv4-hk.txt  ipv4.txt  ipv6-hk.txt  ipv6.txt

每日凌晨十二点非常会进行同步,若须要 IP 地址,能够拜访如下地址:

http://aliyun.chenby.cn/

退出移动版