Skip to content

Instantly share code, notes, and snippets.

@atucom
Created March 19, 2018 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atucom/8e42976ef9416096214c4f4b2af5afb3 to your computer and use it in GitHub Desktop.
Save atucom/8e42976ef9416096214c4f4b2af5afb3 to your computer and use it in GitHub Desktop.
converts 1.1.1.1-1.1.1.4 notation into individual IPs
#!/usr/bin/env python3
#pip3 install iptools
#converts 1.1.1.1-1.1.1.4 notation into individual IPs
#@atucom
import iptools
with open('ips.txt') as f:
lines = f.readlines()
for line in lines:
if '-' in line:
iprange = line.split('-')
start, end = iprange[0], iprange[1]
ips = iptools.IpRange((start,end))
for ip in ips:
print(ip)
else:
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment