nanog mailing list archives

Re: subnet aggregation script


From: Jeff Walter <jeffw () he net>
Date: Mon, 21 Sep 2009 16:42:08 -0700

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 ()));


Current thread: