Created
March 19, 2018 15:16
-
-
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
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
#!/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