I've created a small script for generating RFC 4319 (the IPv6 replacement of RFC 1918 addresses) compliant IPv6 addresses.


my $v6prefix = 278176441827328 + int rand(1099511627775);
$v6prefix = sprintf("%x", $v6prefix);
$v6prefix =~ s/(\w{4})(\w{4})(\w{4})/$1:$2:$3::\/48/;

print "Unique local IPv6 prefix is $v6prefix\n";

RFC 4319 specifies that these addresses are 48 bit prefixes with the most significant 8 bits being FD, for locally administered prefixes. 1099511627775 is the upper limit of the 40 random bits. Adding 278176441827328 is the FD prefix.