Get VM guests MAC Address Script
Posted on October 15th, 2008 in Tips | 1 Comment »
This is just to share a simple script – “How to find out VM guest MAC address for each VMware ESX” server as below:
## Script START here
#!/bin/bash
#
# Get VM Guest Mac Address – getmacadd.sh
#
# The getmacadd.sh script must run as root on VMware ESX server.
#
# This work is licensed under a Creative Commons License permitting non-commercial sharing with attribution
#
# Change Log:
# 15 Oct 2008 – version 0.1
#
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
id_check() {
if [ `id -u` -ne 0 ]
then
echo “You must be root to run this script!”
exit
fi
}
id_check
for COUNT in $(vmware-cmd -l); do
echo `echo $COUNT|awk -F’/’ ‘{print $6}’`
echo ” “`echo $COUNT`
echo ” “`cat $COUNT|grep “displayName”`
#MAC Address may refer to “Address” instead of “generatedAddress”
echo ” “`cat $COUNT|grep “generatedAddress”`
echo
done
## Script END here
