Skip to content

Instantly share code, notes, and snippets.

@craigderington
Created January 17, 2019 17:46
Show Gist options
  • Save craigderington/ec4d7c5ef946857879aada884e089c7d to your computer and use it in GitHub Desktop.
Save craigderington/ec4d7c5ef946857879aada884e089c7d to your computer and use it in GitHub Desktop.
from random import randrange
def get_random_ip():
"""
Create a random IP address
:return: ipv4 address
"""
return ".".join(str(randrange(1, 255)) for i in range(4))
def main():
"""
Program entry point
:return:
"""
rfc1918 = [10, 127, 172, 192]
counter = 0
ceiling = 1000000
while counter <= ceiling:
ip = get_random_ip()
if ip.split(".")[0] not in rfc1918:
print(str(ip))
counter += 1
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment