Created
August 8, 2018 13:58
-
-
Save matthewbdaly/228f5dd3064a66278ebb8bc05d6ef00f to your computer and use it in GitHub Desktop.
Expand a list of IP addresses with Python 3
This file contains 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 characters
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