2017年5月25日 星期四

用APNIC找出台灣所有的IP位址

台灣的IP網段

台灣的IP地址是由APNIC(亞太網路資訊中心)分配,所以在APNIC官網上就可以查詢到最新分配给亞洲各國網段資料(當然包含台灣囉)。

連接以下的網址 http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest網友們就可以得到亞太地區的AS號和網段分配情况,如下:

######################################################################
#
#  CONDITIONS OF USE
# ____________________________________________________________________
# 
# 
# The files are freely available for download and use on the condition 
# that APNIC will not be held responsible for any loss or damage 
# arising from the use of the information contained in these reports.
# 
# APNIC endeavours to the best of its ability to ensure the accuracy 
# of these reports; however, APNIC makes no guarantee in this regard.
# 
# In particular, it should be noted that these reports seek to 
# indicate where resources were first allocated or assigned. It is not
# intended that these reports be considered as an authoritative 
# statement of the location in which any specific resource may 
# currently be in use.
# 
# For more information see: 
#
#       http://www.apnic.net/db/rir-stats-format.html
# or
# ftp://ftp.apnic.net/pub/apnic/stats/apnic/README.TXT
#
######################################################################
#
2|apnic|20170525|51743|19830613|20170524|+1000
apnic|*|asn|*|7756|summary
apnic|*|ipv4|*|37477|summary
apnic|*|ipv6|*|6510|summary
apnic|JP|asn|173|1|20020801|allocated
apnic|NZ|asn|681|1|20020801|allocated
apnic|AU|asn|1221|1|20000131|allocated
apnic|JP|asn|1233|1|20020801|allocated
apnic|KR|asn|1237|1|20020801|allocated
apnic|SG|asn|1250|1|20020801|allocated
apnic|TW|asn|1659|1|20020801|allocated
apnic|KR|asn|1704|1|20020801|allocated
apnic|TW|asn|1768|2|20020801|allocated
apnic|KR|asn|1781|1|20020801|allocated
apnic|AU|asn|1851|1|20020801|allocated
 
 
 
檔案格式的說明如下:

配發的機構 | 國家代碼|IP版本| 分配網段 | 分配IP數量 | 分配時間 | 狀態

apnic|TW|asn|1659|1|20020801|allocated
 
 
因此,若要取得該國的網段,這還需要再做進一步的IP Mask計算處理:


wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | awk -F\| '/TW\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > ./tw_ip.list

這樣就會取得所有台灣的IP網段~~ :)


但是有網友需要所有的IP位址,這下就要花點小技巧囉:
首先請到 Github上面安裝 ipgen 這個專案項目

1.安装ipgen



$ git clone https://github.com/royhills/ipgen.git
$ cd ipgen
$ autoreconf --install
$ ./configure
$ make
$ make check
$ sudo make install


  注意事前必須先安装 automake 和 autoconf 套件

 

2. IP Generation Script

#!/bin/bash
while read line
do

        ipgen $line | tee -a ./tw.ip_address.list
done < ./tw_ip.list


所以全台灣的IP檔案大小約 489MB, 35,510,560 個IP(約3千多萬組IP)
<那.....中國有多少??>


是的~~
中國的IP檔案大小約 4.6GB, 338,261,890 個IP(約3億3千多萬組IP)

 


1 則留言:

  1. James的資訊安全實驗室: 用apnic找出台灣所有的ip位址 >>>>> Download Now

    >>>>> Download Full

    James的資訊安全實驗室: 用apnic找出台灣所有的ip位址 >>>>> Download LINK

    >>>>> Download Now

    James的資訊安全實驗室: 用apnic找出台灣所有的ip位址 >>>>> Download Full

    >>>>> Download LINK

    回覆刪除

用APNIC找出台灣所有的IP位址