Created
January 17, 2019 17:46
-
-
Save craigderington/ec4d7c5ef946857879aada884e089c7d to your computer and use it in GitHub Desktop.
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 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