Skip to content

Instantly share code, notes, and snippets.

@wankdanker
Last active December 14, 2015 16:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wankdanker/2f676cc85f52fd471567 to your computer and use it in GitHub Desktop.
Save wankdanker/2f676cc85f52fd471567 to your computer and use it in GitHub Desktop.
Generate a mac address based on FQDN

Install

curl https://gist.githubusercontent.com/wankdanker/2f676cc85f52fd471567/raw -o /usr/local/bin/gen-mac; chmod 755 /usr/local/bin/gen-mac
#!/usr/bin/env bash
#from http://serverfault.com/questions/299556/how-to-generate-a-random-mac-address-from-the-linux-command-line
if [ -z "$1" ];
then
echo "usage: $0 fully.qualified.domain.name";
exit 1
fi
FQDN=$1
echo $FQDN|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment