VMware Cloud Community
Riplakish
Contributor
Contributor

Resetting Management/Kernel MACs to HW MAC address

I admit I'm doing something a little bit off the beaten path, but I'm hoping there is a quick solution to get me out of the hole I've dug.

I'm trying to automate the deployment of dozens of ESXi hosts. So far, I'm grabbing a block level image of the boot drive, and writing back out to the destination systems.

Unfortuantely, it appears that the MAC address for the kernel interface on the default vSwitch (and possibly others - this is the one biting me right now) is saved in /etc/vmware/esx.conf, and brought along during the process. Once the new machine comes up, I get 2 machines using the same MAC (more if I do a large scale duplication), and network problems ensue.

I've found that if I clear the MACs from the esx.conf file before taking the image, the destination machine creates a new one on the fly as it boots. However, its still not the MAC reported by the console interface (which shows the HW address), and not the HW address.

Is there any way to reset the various MACs to the HW value? Extra kudos if someone can point me at a mechanism to have it occur automatically on first boot.

  -B

0 Kudos
1 Reply
nirvy
Commander
Commander

Something like this should do it

MACADDR=`esxcfg-nics -l | grep vmnic0 | awk '{print $7}'`

esxcfg-init --vmknic vmk0 --mac-address $MACADDR

You could append it to the bottom of /etc/rc.local on your source ESXi host.  I think then you just need to run auto-backup.sh to have the changes persist between reboots.  When your cloned hosts boot, this will run and change the MAC address to the physical address.  To have it run once, just backup rc.local first, then replace your modified rc.local with the original file once the above commands have run, calling auto-backup.sh to permanently save the changes.

With cloning ESXi, everytime you create a vmk there is a likelyhood of duplicate vmk mac conflict though.  Also your local disks will likely have identical UUID's which is never a good thing.  Have you thought about using a kickstart script or autodeploy?

Cheers

Mark

0 Kudos