星期四, 10月 13, 2011

Random MAC Generation

I found 3 scripts:

#openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'

#dd if=/dev/urandom count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/'

#ruby -e ‘print (“%02x”%((rand 64).to_i*4|2))+(0..4).inject(“”){|s,x|s+”:%02x”%(rand 256).to_i} + “\n”‘

(python??)

I would suggest assigning the first two or three octets with fixed value and let scripts generate the rest. Make sure the first octet is EVEN. (MAC address starting with odd octet is for multicast)