Last active
August 29, 2015 14:10
-
-
Save h3xxx/dbb5eb30e146b79bce77 to your computer and use it in GitHub Desktop.
Generate random IP addresses
This file contains hidden or 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/python | |
import sys | |
import random | |
count = 10 # default value | |
if len(sys.argv) > 1: | |
try: | |
count = int(sys.argv[1]) | |
except ValueError: | |
pass # bad input, should be int value, using default value | |
for x in range(0, count): | |
ip = ".".join(map(str, (random.randint(0, 255) | |
for _ in range(4)))) | |
print ip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment