When imaging ESX you might experience issues with duplicate MAC address or on a system that use DHCP
Possible issues when the vmkernel is created, the MAC address of the vmkernel it might not always match the physical is some environments where DHCP is issued to the physical NIC MAC DHCP will fail
When using imaging to backup and restore or to deploy a new ESX server you can end up with a vmkernel that has a different MAC either auto generated or will match the MAC from the original system
There is a VMware KB on the issue http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=103111...
I was unable to get the command /Net/FollowHardwareMac to 1 to work
The resolution for my on demand scenario where we need to execute this command every time deployed
1. Create a script using the following or cut and paste the commands into /ect/rc.local.d.local.sh on esx 5.1 on 5.0 and lower use /etc/rc.local
If you only want this command run once then do not leave the commands in /ect/rc.local.d.local.sh or /etc/rc.local
Sleep command is critical with out this delay the script executes too fast during the boot process and script will not work at boot time,
The script works fine without the sleep command if the system is already up and running good for one off use case.
----------------------------------------------------------------------------------------------------
#Delays the script for 60 seconds
sleep 60
#Detects the MAC address on vmnic0
MAC=`esxcli network nic list | grep
vmnic0 | awk
'{print $7}'`
#Removes the vmkernel
esxcli network ip interface remove -i vmk0
#Adds the vmkernal and specifys the MAC address as the same as the MAC on vmnic0
esxcli network ip interface add -i vmk0 -M $MAC -p "Management Network"
#Sets the vmkernel to DHCP
esxcli network ip interface ipv4 set
-i vmk0 -t dhcp
--------------------------------------------------------------------------------------------------------------------