Route summarization for IP networks is the way to make things more sufficient, to make things easier, to save resources. I had to summarize 30000 IPv4 route entries but the tool that has been used could not summarize more entries than 8092 in a row. This has been the call to write my personal IP route route summarization tool, but a quick search with a search engine revealed there are people out there that had the idea and have written their tools.
This is a perl script written by Adrian Popa, a network engineer. It does only one job, summarizing a lot of IP network entries into supernets. Here is Adrian Popa's route sumarization perl script.
This script looks like this below, actually this is a copy of the original:
#!/usr/bin/perl
# Author : Adrian Popa
# http://adrianpopagh.blogspot.com/2008/03/route-summarization-script.html
use strict;
use warnings;
use Net::CIDR::Lite;
my $ipv4String='[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';
if(defined $ARGV[0] && $ARGV[0] eq '-h'){
print "usage: $0
This script summarizes your IP classes (if possible). Input IPs with mask one per line. End with CTRL+D. Optionally, redirect a file to stdin like so:
$0 < cidr.txt ";
exit;
}
print "Enter IP/Mask one per line (1.2.3.0/24). End with CTRL+D.\n";
my $cidr =Net::CIDR::Lite->new;
while(<>){
if(/($ipv4String\/[0-9]{1,2})/){
my $item=$1;
$cidr->add($item);
}
else{
print "Ignoring previous line.\n";
}
}
my @cidr_list = $cidr->list;
print "======Aggregated IP list:======\n";
foreach my $item(@cidr_list){
print "$item\n";
}
Below some facts. How many /24 IP prefixes does the file have:
The file has more than 30000 /24 IP entries, exactly 31579 network entries. How many entries are different than /24 CIDR subnetmask:
The answer is, it has only /24 networks. Now let us run the script and verify how many network entries will be there after the summarization has finished:
Using this script it is possible to save lot of resources like memory and CPU and time. In my case the script has been been able to summarize every 6-th IPv4 entry.