mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-18 20:47:55 +00:00
etc/functions: Add a function to generate random MAC address
This commit is contained in:
parent
fb5cfd5cc2
commit
37a343a49c
@ -374,3 +374,9 @@ print_battery_charge()
|
||||
echo "$battery_charge"
|
||||
fi
|
||||
}
|
||||
|
||||
generate_random_mac_address()
|
||||
{
|
||||
#Borrowed from https://stackoverflow.com/questions/42660218/bash-generate-random-mac-address-unicast
|
||||
hexdump -n 6 -ve '1/1 "%.2x "' /dev/urandom | awk -v a="2,6,a,e" -v r="$RANDOM" 'BEGIN{srand(r);}NR==1{split(a,b,",");r=int(rand()*4+1);printf "%s%s:%s:%s:%s:%s:%s\n",substr($1,0,1),b[r],$2,$3,$4,$5,$6}'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user