Last active
May 13, 2019 18:43
-
-
Save mchangrh/40dc1a63c873e1da387e7734e79db837 to your computer and use it in GitHub Desktop.
MAC Address Generation from FQDN
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
#/bin/bash | |
# title :MacGen | |
# description :Randomly Generate MAC from FQDN | |
# author :mchangrh | |
# source :https://repl.it/@mchangrh/MacGen | |
#========== | |
# Read Hostname | |
read -p 'Enter Hostname:' host | |
# Establish Prefixes | |
# Locally Administered Addresses | |
LAA1='02:00:00'; LAA2='06:00:00'; LAA3='0A:00:00'; LAA4='0E:00:00' | |
# Hyper-V and VMM Virtual Machines | |
MSFT1='00:03:FF'; MSFT2='00:0D:3A'; MSFT3='00:15:5D'; MSFT5='00:17:FA'; MSFT6='00:50:F2' | |
# VMWare Virtual Machines | |
VMWARE1='00:58:69'; VMWARE2='00:0C:29'; VMWARE3='00:1C:14' | |
# Choose Prefix | |
select range in LAA{1..4} MSFT1{1..6} VMWARE{1..3}; do | |
# Set prefix to variable with maching name | |
prefix=${!range}; break; done | |
# Generate Random MAC | |
echo $host|md5sum|sed 's/^\(..\)\(..\)\(..\).*$/'$prefix':\1:\2:\3/' | |
# BASED OFF OF SCRIPT FROM: | |
# https://serverfault.com/a/299563 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment