IP range to CIDR conversion
Thu, 05/15/2008 - 10:19 — sandipI'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("$A RGV[0]")) . "\n";