You can easily generate valid ULAs in bash by only using the builtin printf
and the special Bash variable $RANDOM
:
printf "fd%x:%x:%x:%x::/64\n" "$(( $RANDOM/256 ))" "$RANDOM" "$RANDOM" "$RANDOM"
Running this several times on my own machine give me a bunch of freshly-minted (and more importantly, valid) ULA addresses with random subnet ids:
fd45:364c:99:6690::/64
fd19:59c8:7e73:30d7::/64
fd0c:4ebe:60ce:7a02::/64
...
If you want to only use one ULA network and multiple subnet ids per site, leave out the last two bytes and assign the subnet id manually as required:
fd45:364c:99::/64
fd45:364c:99:1::/64
fd45:364c:99:2::/64
Before you use a ULA, make sure to run the command a couple of times to make sure that your $RANDOM
is giving out random values. If it isn't, start a fresh bash session and make sure you're not doing anything to the random variable.