Skip to content

Instantly share code, notes, and snippets.

@menski
Created July 11, 2012 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save menski/3093082 to your computer and use it in GitHub Desktop.
Save menski/3093082 to your computer and use it in GitHub Desktop.
Generate random IPv6 addresses
import random
import itertools
network = "2001:0db8:85a3:08d3"
N = 34 # number of permutation elements
with open('ipv6-list.txt', 'w') as f:
for addr in itertools.permutations(random.sample(range(64 ** 2), N), 4):
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