Skip to content

Instantly share code, notes, and snippets.

@akhil-reni
Created November 9, 2019 13:05
Show Gist options
  • Save akhil-reni/5c248544f3247e3cf0b6d8e4ae3ab5fe to your computer and use it in GitHub Desktop.
Save akhil-reni/5c248544f3247e3cf0b6d8e4ae3ab5fe to your computer and use it in GitHub Desktop.
cat cidr.txt | python3 cidrtoips.py
import ipaddress
import fileinput
ips = []
for line in fileinput.input():
try:
ips.extend(list(ipaddress.ip_network(line.strip())))
except:
pass
print('\n'.join(map(str, ips)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment