2008年12月18日星期四

获得台湾ipv4地址段

台湾地区ipv4地址分为两部分,一部分是从twnic申请,令一部分是直接从apnic申请。

获得twnic分配的ip地址
页面
http://rms.twnic.net.tw/twnic/User/Member/Search/main7.jsp?Order=ORG.ID
提供了twnic分配的ip地址情况,

for i in `wget -qO- "http://rms.twnic.net.tw/twnic/User/Member/Search/main7.jsp?Order=ORG.ID" | awk -F'[-<]' '/^[1-9].*255/ {print $1":"$2}' | tr -d ' ' | sort -nu`

do N=$N`netmask $i`

done

netmask $N

awk命令解析:
-F: 后面跟分隔符
/^[1-9].*255/:正则表达式匹配,获取ip地址段
{print $1":"$2}: 用":"作分隔符,打印ip地址范围条目

如果要以标准的netmask来呈现结果,即型如255.255.255.0格式的掩码

netmask -s $N

用這個 script 可以取得台灣 IP 的網段, 需先安裝 netmask (可以計算網段資料及把網段做 summary)

58.86.0.0/16
58.99.64.0/18
59.104.0.0/15
59.112.0.0/12
60.198.0.0/15
60.244.128.0/17
60.245.64.0/19
60.248.0.0/14
61.20.0.0/16
61.30.0.0/15
61.56.64.0/20
61.57.240.0/20
61.58.48.0/20
61.59.0.0/16
61.60.240.0/20
61.61.240.0/20
61.62.0.0/16
61.63.32.0/19
61.63.64.0/19
61.64.32.0/20
61.65.192.0/18
61.66.0.0/16
61.67.112.0/20
61.216.0.0/13
61.224.0.0/13
61.247.160.0/20
113.21.160.0/19
113.61.128.0/17
114.24.0.0/14
114.30.32.0/20
114.32.0.0/12
114.136.0.0/15
114.140.0.0/16
114.198.160.0/20
115.30.64.0/18
115.42.112.0/21
115.43.0.0/16
115.80.0.0/14
115.85.144.0/20
115.165.192.0/18
116.50.32.0/20
116.59.0.0/16
116.89.128.0/20
116.118.128.0/18
116.212.80.0/20
117.19.0.0/16
117.56.0.0/16
117.103.96.0/20
118.160.0.0/13
118.168.0.0/14
118.231.0.0/16
118.232.0.0/15
119.14.0.0/16
119.15.192.0/18
119.30.16.0/20
119.31.176.0/20
119.75.240.0/20
119.77.128.0/17
120.96.0.0/11
121.50.176.0/20
122.99.0.0/18
122.100.64.0/18
122.116.0.0/15
122.118.0.0/16
122.120.0.0/13
122.128.80.0/21
122.146.0.0/15
122.200.152.0/21
122.201.128.0/17
122.252.160.0/20
122.254.0.0/18
122.255.80.0/20
123.0.32.0/19
123.50.32.0/19
123.99.32.0/19
123.110.0.0/16
123.192.0.0/14
123.204.0.0/15
123.240.0.0/15
123.252.0.0/17
124.6.0.0/19
124.8.0.0/14
124.12.0.0/16
124.29.128.0/19
124.108.128.0/18
124.109.112.0/20
124.155.160.0/19
124.199.64.0/19
124.218.0.0/16
124.219.0.0/17
125.224.0.0/13
125.232.0.0/15
139.175.0.0/16
140.109.0.0/16
140.110.0.0/15
140.112.0.0/12
140.128.0.0/13
140.136.0.0/15
140.138.0.0/16
163.13.0.0/16
163.14.0.0/15
163.16.0.0/12
163.32.0.0/16
168.95.0.0/16
192.72.3.0/24
192.83.194.0/24
192.192.0.0/16
202.3.129.0/24
202.5.4.0/23
202.6.104.0/23
202.8.14.0/23
202.39.128.0/17
202.144.208.0/20
202.148.208.0/20
202.151.48.0/20
202.160.64.0/19
202.168.192.0/20
202.169.160.0/20
202.174.16.0/20
202.178.128.0/17
203.64.0.0/16
203.65.160.0/19
203.66.0.0/15
203.68.0.0/14
203.72.0.0/14
203.78.176.0/20
203.79.128.0/17
203.84.144.0/21
203.111.208.0/20
203.118.224.0/20
203.119.3.0/24
203.121.240.0/20
203.145.192.0/20
203.160.144.0/20
203.190.16.0/21
203.201.32.0/20
203.207.32.0/20
210.58.0.0/16
210.59.128.0/17
210.60.0.0/15
210.62.192.0/19
210.63.224.0/19
210.64.0.0/15
210.66.0.0/16
210.67.96.0/20
210.68.0.0/15
210.70.0.0/16
210.71.128.0/17
210.85.0.0/16
210.200.0.0/15
210.202.32.0/20
210.203.0.0/17
210.240.0.0/16
210.241.160.0/19
210.242.0.0/17
210.243.128.0/17
210.244.192.0/19
211.20.0.0/14
211.72.128.0/17
211.73.32.0/19
211.74.0.0/17
211.75.128.0/17
211.76.192.0/19
211.77.0.0/18
211.78.80.0/20
211.79.192.0/20
218.32.0.0/16
218.34.0.0/15
218.160.0.0/12
218.184.0.0/16
218.187.0.0/16
218.210.0.0/15
219.80.0.0/15
219.84.0.0/14
219.91.0.0/17
220.128.0.0/18
220.129.0.0/16
220.130.0.0/15
220.132.0.0/14
220.136.0.0/13
220.157.112.0/20
220.228.0.0/15
221.120.0.0/18
221.120.64.0/19
221.169.0.0/16
222.156.0.0/15
222.250.0.0/16
222.251.0.0/17


获得apnic分配的ip地址

http://ftp.apnic.net/stats/apnic/delegated-apnic-latest
要取得台灣的 IP, 要用此份資料比較全
netmask `wget -qO- http://ftp.apnic.net/stats/apnic/delegated-apnic-latest | awk -F'|' '/TW\|ipv4/ {print $4":+"($5-1)}'`

如果要以标准的netmask来呈现结果,即型如255.255.255.0格式的掩码

netmask -s `wget -qO- http://ftp.apnic.net/stats/apnic/delegated-apnic-latest | awk -F'|' '/TW\|ipv4/ {print $4":+"($5-1)}'`

用這行可以取得台灣所有的 IP 網段

58.86.0.0/16
58.99.0.0/17
58.114.0.0/15
59.104.0.0/15
59.112.0.0/12
60.198.0.0/15
60.244.0.0/16
60.245.0.0/17
60.248.0.0/14
61.20.0.0/16
61.30.0.0/15
61.56.0.0/13
61.64.0.0/14
61.70.0.0/15
61.216.0.0/13
61.224.0.0/13
61.247.160.0/20
113.21.80.0/20
113.21.160.0/19
113.61.128.0/17
113.196.0.0/16
114.24.0.0/14
114.30.32.0/20
114.32.0.0/12
114.136.0.0/15
114.140.0.0/16
114.198.160.0/19
115.30.64.0/18
115.42.112.0/21
115.43.0.0/16
115.80.0.0/14
115.85.144.0/20
115.165.192.0/18
116.50.32.0/20
116.59.0.0/16
116.89.128.0/20
116.118.128.0/18
116.212.80.0/20
116.214.0.0/20
117.19.0.0/16
117.56.0.0/16
117.103.96.0/20
118.160.0.0/13
118.168.0.0/14
118.231.0.0/16
118.232.0.0/15
119.14.0.0/16
119.15.192.0/18
119.30.16.0/20
119.31.176.0/20
119.75.240.0/20
119.77.128.0/17
119.160.240.0/20
120.96.0.0/11
121.50.144.0/21
121.50.176.0/20
121.254.64.0/18
122.99.0.0/18
122.100.64.0/18
122.116.0.0/15
122.118.0.0/16
122.120.0.0/13
122.128.80.0/21
122.144.32.0/19
122.146.0.0/15
122.200.152.0/21
122.201.128.0/17
122.252.160.0/20
122.254.0.0/18
122.255.80.0/20
123.0.32.0/19
123.0.192.0/18
123.50.32.0/19
123.51.128.0/17
123.99.0.0/18
123.110.0.0/16
123.192.0.0/14
123.204.0.0/15
123.240.0.0/15
123.252.0.0/17
123.255.224.0/21
124.6.0.0/19
124.8.0.0/14
124.12.0.0/16
124.29.128.0/18
124.108.128.0/18
124.109.112.0/20
124.155.128.0/18
124.199.64.0/19
124.199.96.0/20
124.218.0.0/16
124.219.0.0/17
125.62.224.0/20
125.224.0.0/13
125.232.0.0/15
134.208.0.0/16
139.175.0.0/16
139.223.0.0/16
140.92.0.0/16
140.96.0.0/16
140.109.0.0/16
140.110.0.0/15
140.112.0.0/12
140.128.0.0/13
140.136.0.0/15
140.138.0.0/16
163.13.0.0/16
163.14.0.0/15
163.16.0.0/12
163.32.0.0/16
168.95.0.0/16
169.211.3.0/24
192.72.3.0/24
192.72.4.0/22
192.72.8.0/21
192.72.16.0/20
192.72.32.0/19
192.72.64.0/18
192.72.128.0/22
192.72.133.0/24
192.72.134.0/23
192.72.136.0/21
192.72.144.0/20
192.72.160.0/19
192.72.192.0/19
192.72.224.0/20
192.72.240.0/21
192.72.248.0/22
192.72.252.0/24
192.83.166.0/23
192.83.168.0/24
192.83.170.0/23
192.83.172.0/22
192.83.176.0/20
192.83.192.0/22
192.83.196.0/24
192.188.171.0/24
192.192.0.0/16
202.2.52.0/22
202.3.129.0/24
202.3.160.0/19
202.5.4.0/23
202.5.8.0/21
202.5.224.0/19
202.6.104.0/23
202.8.14.0/23
202.8.160.0/19
202.14.8.0/21
202.39.0.0/16
202.55.224.0/19
202.80.104.0/21
202.126.64.0/20
202.132.0.0/16
202.133.224.0/19
202.144.208.0/20
202.145.32.0/19
202.145.64.0/18
202.145.128.0/17
202.148.208.0/20
202.151.48.0/20
202.153.160.0/19
202.153.192.0/20
202.154.192.0/19
202.159.128.0/18
202.160.64.0/19
202.165.120.0/21
202.165.128.0/19
202.166.224.0/19
202.168.192.0/20
202.169.160.0/20
202.173.32.0/19
202.174.4.0/24
202.174.16.0/20
202.178.128.0/17
203.64.0.0/13
203.72.0.0/14
203.77.0.0/17
203.78.0.0/22
203.78.176.0/20
203.79.128.0/17
203.84.130.0/23
203.84.144.0/21
203.91.0.0/19
203.95.128.0/17
203.105.224.0/19
203.107.0.0/18
203.111.208.0/20
203.118.224.0/20
203.119.3.0/24
203.121.224.0/19
203.133.0.0/17
203.135.64.0/19
203.145.192.0/19
203.148.92.0/24
203.160.144.0/20
203.160.224.0/19
203.163.192.0/19
203.187.0.0/17
203.188.192.0/20
203.190.4.0/22
203.190.16.0/21
203.201.32.0/20
203.203.0.0/16
203.204.0.0/16
203.207.0.0/20
203.207.32.0/20
203.211.0.0/19
203.217.96.0/19
203.222.0.0/19
210.17.0.0/17
210.58.0.0/15
210.60.0.0/14
210.64.0.0/13
210.80.64.0/19
210.85.0.0/16
210.192.0.0/18
210.192.128.0/17
210.200.0.0/15
210.202.0.0/16
210.203.0.0/17
210.208.0.0/16
210.209.0.0/18
210.209.128.0/17
210.240.0.0/14
210.244.0.0/16
211.20.0.0/14
211.72.0.0/13
218.32.0.0/16
218.34.0.0/15
218.160.0.0/12
218.184.0.0/16
218.187.0.0/16
218.210.0.0/15
219.68.0.0/14
219.80.0.0/15
219.84.0.0/14
219.90.0.0/18
219.91.0.0/17
220.128.0.0/12
220.157.112.0/20
220.228.0.0/15
220.247.128.0/19
221.120.0.0/18
221.120.64.0/19
221.169.0.0/16
222.156.0.0/15
222.250.0.0/16
222.251.0.0/17

标签:


评论: 发表评论

订阅 博文评论 [Atom]





<< 主页

This page is powered by Blogger. Isn't yours?

订阅 博文 [Atom]