Ctyr
2/20/2015 - 1:09 PM

generet random legel mac address

generet random legel mac address

#!/bin/bash
#Description:this program automatically generates random legal mac address
#Ver.2.0	2014-10-26
#Author:Tyr
#Usage:./random_mac.sh [num]
i=0
while [ "$i" -lt "$1" ]
do
	random=$(hexdump -n6 -e '/1 ":%02x"' /dev/urandom)
 	if echo $random | grep -q '*';then
		continue
 	fi
	octet=`echo $random | cut -d : -f2`
	shi=$((0x${octet}))
	flag=$(($shi%2))
	if [ $flag -eq 0 ];then
		mac=`echo $random | sed 's/^://g'`
		echo $mac
		i=$((i+1))
	fi
done