cidr

IP range to CIDR conversion

I've often had to convert IP range with netmask to a CIDR notation. Below is a quick perl script to help with the conversion:

#!/usr/bin/perl -w
# range2cidr.pl

use Net::CIDR;
use Net::CIDR ':all';

if (@ARGV == 0) {
  die "Usage Example: $0 192.168.0.0-192.168.255.255 \n";
}

print join("\n", Net::CIDR::range2cidr("$ARGV[0]")) . "\n";

Syndicate content
Comment