Skip to content

Instantly share code, notes, and snippets.

@dmehrotra
Created December 7, 2018 17:33
Show Gist options
  • Save dmehrotra/491d45dfb1adf90e5840ca6de03b788d to your computer and use it in GitHub Desktop.
Save dmehrotra/491d45dfb1adf90e5840ca6de03b788d to your computer and use it in GitHub Desktop.
import sys
import ipaddress
fi = sys.argv[1]
count = 0
with open(fi) as f:
for i,line in enumerate(f):
network = line.split(',')[0]
if (network != 'network' and network != '\n'):
net = ipaddress.ip_network(network)
for x in net.hosts():
count = count+1
print (count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment