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";

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

cool, thanks :)

You made my day :) This is exactly what I need: a perl script to use within Webmin.

great script!

Thanks!

thanks man ! this was very

thanks man ! this was very useful !!

Comment