Skip to content

Instantly share code, notes, and snippets.

@mekza
Created October 12, 2012 09:58
Show Gist options
  • Save mekza/3878481 to your computer and use it in GitHub Desktop.
Save mekza/3878481 to your computer and use it in GitHub Desktop.
IP Range
def IPRange(start_ip, end_ip):
"""
Gen IP Range
"""
start = list(map(int, start_ip.split(".")))
end = list(map(int, end_ip.split(".")))
temp = start
ip_range = []
ip_range.append(start_ip)
while temp != end:
start[3] += 1
for i in (3, 2, 1):
if temp[i] == 256:
temp[i] = 0
temp[i-1] += 1
ip_range.append(".".join(map(str, temp)))
return ip_range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment