Created
February 20, 2015 13:09
-
-
Save tyr0chen/6a137a6e645af0236797 to your computer and use it in GitHub Desktop.
generet random legel mac address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment