Skip to content

Instantly share code, notes, and snippets.

@lanbugs
Created May 12, 2023 17:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Compress list of subnets and ips
import sys
from netaddr import cidr_merge
def main(FILE):
with open(FILE) as f:
raw_lines = f.readlines()
subnets = []
for line in raw_lines:
subnets.append(line.strip())
subnets = cidr_merge(subnets)
for subnet in subnets:
print(subnet)
if __name__ == "__main__":
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment