Skip to content

Instantly share code, notes, and snippets.

@matthewbdaly
Created August 8, 2018 13:58
Show Gist options
  • Save matthewbdaly/228f5dd3064a66278ebb8bc05d6ef00f to your computer and use it in GitHub Desktop.
Save matthewbdaly/228f5dd3064a66278ebb8bc05d6ef00f to your computer and use it in GitHub Desktop.
Expand a list of IP addresses with Python 3
from ipaddress import ip_network
ip_ranges = [
'192.168.1.0/24',
]
with open('whitelisted.csv', 'w') as f:
for ip_range in ip_ranges:
net = ip_network(ip_range)
for ip in net:
f.write(str(ip) + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment