[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
subnet aggregation script
- Subject: subnet aggregation script
- From: jeffw at he.net (Jeff Walter)
- Date: Mon, 21 Sep 2009 16:42:08 -0700
- In-reply-to: <98E72206041B1B408D3F92E91E80BF1802750530@slmail101.softlayer.local>
- References: <98E72206041B1B408D3F92E91E80BF1802750530@slmail101.softlayer.local>
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 ()));