#!/bin/bash

# Random generator ipv6 addresses within your ipv6 network prefix.
# Copyright
# Vladislav V. Prodan
# universite@ukr.net
# 2011

array=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )

rnd_ip_block ()
{
    if [ -z "$1" ]; then
	echo "Usage: rnd_ip_block prefix"
    fi
    a=${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}
    b=${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}
    c=${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}
    d=${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}${array[$RANDOM%16]}
    echo $1:$a:$b:$c:$d
}
