Last active
September 26, 2018 03:55
-
-
Save SilvM/325c4754b83ea91fffe553530bb87451 to your computer and use it in GitHub Desktop.
Summarise list of IPs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simplest way I know to summarise a list of subnets | |
import netaddr as ip | |
ips = [ip.IPNetwork(line.rstrip('\n')) for line in open('ip_prefixes2')] | |
ip.cidr_merge(ips) | |
# More info at https://netaddr.readthedocs.io/en/latest/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment