Skip to content

Instantly share code, notes, and snippets.

@menski
Created July 11, 2012 20:50
Show Gist options
  • Save menski/3093337 to your computer and use it in GitHub Desktop.
Save menski/3093337 to your computer and use it in GitHub Desktop.
Generate random IPv6 adresses (cartesian product)
import random
import itertools
network = "2001:0db8:85a3:08d3"
with open('ipv6-list.txt', 'w') as f:
sample = lambda x: random.sample(range(64 ** 4), x)
for addr in itertools.product(sample(100), sample(100), sample(10), sample(10)):
f.write(network + ":%04x:%04x:%04x:%04x\n" % addr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment