LoginSignup
5
5

More than 5 years have passed since last update.

CIDRとIP Rangeの変換

Last updated at Posted at 2012-05-21

CIDR(192.168.0.0/16)->IP範囲の変換

コマンド

perl -MNet::CIDR -le 'print(join("\n", Net::CIDR::cidr2range("192.68.0.0/16")))'

出力結果

192.168.0.0-192.168.255.255

IP範囲(192.168.0.0-192.168.255.225)->CIDRの変換

コマンド

perl -MNet::CIDR -le 'print(join("\n", Net::CIDR::range2cidr("192.168.0.0-192.168.255.225")))'

出力結果

192.168.255.0/25
192.168.255.128/26
192.168.255.192/27
192.168.255.224/31
192.168.0.0/17
192.168.128.0/18
192.168.192.0/19
192.168.224.0/20
192.168.240.0/21
192.168.248.0/22
192.168.252.0/23
192.168.254.0/24
  • 複数のCIDRに渡る場合も計算してくれる。
  • 順番の法則性はちょっと謎…。
5
5
0

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
5
5