On Fri, 6 Jun 2014 13:41:37 +1200, Neil Gardner wrote:
My Google-fu has failed me. It defies logic that there aren’t tools (application, Excel based or online) which will take a list of CIDR formatted prefixes and spit out an optimally summarised list also in CIDR notation. I however, can’t find them.
Here's a quick hack job script. You could probably shorten this down and/or make it more robust, but it'll work fine as-is. #!/usr/bin/python # requires Google's `ipaddr' module, from https://pypi.python.org/pypi/ipaddr/ import ipaddr import sys prefixes = [] for prefix in sys.stdin.read().splitlines(False): prefixes.append(ipaddr.IPNetwork(prefix)) summarised_prefixes = ipaddr.collapse_address_list(prefixes) for prefix in summarised_prefixes: print prefix Example usage: mfincham(a)zuse:~$ cat test 10.1.0.0/24 10.1.1.0/24 192.168.23.0/24 mfincham(a)zuse:~$ ./summary.py < test 10.1.0.0/23 192.168.23.0/24 -- Michael