Skip to content

Instantly share code, notes, and snippets.

@h3xxx
Last active August 29, 2015 14:10
Show Gist options
  • Save h3xxx/dbb5eb30e146b79bce77 to your computer and use it in GitHub Desktop.
Save h3xxx/dbb5eb30e146b79bce77 to your computer and use it in GitHub Desktop.
Generate random IP addresses
#!/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