subnet aggregation script

Jeff Walter jeffw at he.net
Mon Sep 21 23:42:08 UTC 2009


Ric Moseley wrote:
> Does anyone know of a tool/script that can aggregate subnets feed to it
> via command line?  Meaning if I give it multiple /30s (or any size
> subnet) it will scrunch them together. 

Here is a Perl script to do just that.  My normal one reads from STDIN.

#!/usr/bin/perl

use Net::CIDR::Lite;

my $cidr = Net::CIDR::Lite->new ();

foreach (@ARGV) {
	if (/^[0-9a-f\.:]+(\/\d+)?$/) {
        	        $cidr->add_any ($_);
         }
}

print (join ("\n", $cidr->list ()));




More information about the NANOG mailing list