Ugh….CIDR

Posted by Nessa | Posted in , | Posted on 28-08-2007

0

I kinda wish I paid attention in class when the professor was talking about CIDR notations and shit…because it would have come in handy tonight. But being that I’m lazy I did some looking around and found that there’s a perl module out there that will convert an IP range to CIDR for you with a simple 4-line script. You’ll need to install the Net::CIDR module for this to work
If you’re on cPanel just type:

# /scripts/perlinstaller Net::CIDR

Here’s the script:

#!/usr/bin/perl

use Net::CIDR;

$range = shift;

print (join(“\n”, Net::CIDR::range2cidr(“$range”)) . “\n” );


Usage:

root@vps [~]# perl convert.pl 192.168.0.1-192.168.1.1
192.168.0.1/32
192.168.0.2/31
192.168.0.4/30
192.168.0.8/29
192.168.0.16/28
192.168.0.32/27
192.168.0.64/26
192.168.0.128/25
192.168.1.0/31

Share and Enjoy:
  • Digg
  • del.icio.us
  • Technorati
  • Facebook
  • Google Bookmarks
  • StumbleUpon
  • Sphinn
  • Mixx
  • blogmarks
  • Furl
  • Reddit
  • Slashdot

Post a comment