LoginSignup
1
2

More than 5 years have passed since last update.

apnic から 国を指定して IP アドレス一覧を取得する

Last updated at Posted at 2016-04-25

必要になったのでそういう Gem を作りました。

Install

gem install search_apnic

一覧を出す

search_apnic -c JP --dump

👇🏼

1.0.16.0/20
1.0.64.0/18
1.1.64.0/18
1.5.0.0/16
1.21.0.0/16
1.33.0.0/16
1.66.0.0/15
1.72.0.0/13
1.112.0.0/14
....

IP アドレスが日本か調べる

search_apnic -c JP -i '192.168.1.1.'

範囲内ならアドレス範囲が、そうでなければ 'Not Match' と出力します。

既知の問題

search_apnic -c JP --dump | head などとすると、Broken pipe @ io_write - <STDOUT> (Errno::EPIPE) になる。
ファイルから読みだすループの途中で止まるからかなと思う。

以下の記事を参考にしました.

http://qiita.com/tt2004d/items/6ffd26612f6c9c9ba047

1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2