Created
January 5, 2015 14:43
-
-
Save DefProc/4f1122d9f591746b554a to your computer and use it in GitHub Desktop.
generate random locally administered MAC address
This file contains 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
# choose the leading octet: | |
echo -en '\x06' | xxd -b | |
# gives: | |
# 0000000: 00000110 | |
# where these ↑↑ digits must be 10 | |
# i.e. an octet with the the hex representation x2, x6, xA or xE | |
# then take the chosen octet and append a random number: | |
echo -n "06:" ; openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//' | |
# if lots need generating, use the first as the initial, and increment the number so there's no collisions | |
# (only a worry with amounts over about 500,000 — see the birthday problem) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment