Last active
October 22, 2021 13:08
-
-
Save wilhelm-murdoch/3e6af107f378ada36e91601aedc636d1 to your computer and use it in GitHub Desktop.
Revisions
-
wilhelm-murdoch revised this gist
Feb 14, 2019 . No changes.There are no files selected for viewing
-
wilhelm-murdoch created this gist
Feb 14, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,75 @@ #!/usr/bin/env python import ipaddr accounts = { 'flood-beta': { 'public': [ '10.1.32.0/20', '10.1.96.0/20', '10.1.160.0/20' ], 'private': [ '10.1.0.0/19', '10.1.64.0/19', '10.1.128.0/19' ], 'spare': [ '10.1.48.0/20', '10.1.112.0/20', '10.1.176.0/20' ] }, 'flood-prod': { 'public': [ '10.2.32.0/20', '10.2.96.0/20', '10.2.160.0/20' ], 'private': [ '10.2.0.0/19', '10.2.64.0/19', '10.2.128.0/19' ], 'spare': [ '10.2.48.0/20', '10.2.112.0/20', '10.2.176.0/20' ] }, 'flood-master': { 'public': [ '10.0.1.0/24', '10.0.2.0/24', '10.0.3.0/24' ], 'private': [ '10.0.0.0/24', '10.0.4.0/24' ], 'spare': [] } } for account, blocks in accounts.iteritems(): print account print '==========' for block, cidrs in blocks.iteritems(): print block + ':' overlapped = False for cidr in cidrs: n1 = ipaddr.IPNetwork(cidr) print '===> ' + cidr for account2, blocks2 in accounts.iteritems(): if account != account2: for block2, cidrs2 in blocks2.iteritems(): for cidr2 in cidrs2: n2 = ipaddr.IPNetwork(cidr2) if n1.overlaps(n2): overlapped = True print '---> overlaps ' + cidr2 + ' in ' + account2 if not overlapped: print 'all clear' print print