Quick Tip: How to change the MAC address on a vSphere VM by editing the VMX file

Someone may know that a vSphere 8.0 Update 2 bug prevents you from setting a static MAC address for a VM (KB 95189).

The symptom is simple – you change the MAC address in the VM’s network interface settings, but after you click OK, nothing changes.

As a workaround, there is a solution – do the same using vSphere Host Client (ESXi Web interface). But in my case, this workaround doesn’t help, I’ve received an error:

Failed to reconfigure virtual machine pleasechangemymac. Invalid configuration for device '4'.

If you are in this situation and you need to change a VM MAC address, one good old hack still works – edit the VM’s VMX file.

Next – how to change the MAC address.

The solution is simple:

  • Power off the VM and remove it from the inventory;
  • Enable SSH on the ESXi, and connect via SSH;
  • Find the VM’s files location on the datastore and move to it:
cd /vmfs/volumes/vsanDatastore/pleasechangemymac/
  • Edit VM’s VMX file:
vi ./pleasechangemymac.vmx
  • Find the network interface section and change address type and MAC address from:
ethernet0.addressType = "vpx"
ethernet0.generatedAddress = "00:50:56:aa:e5:b6"

To:

ethernet0.addressType = "static"
ethernet0.address = "11:22:33:44:55:66"

Please note that depending on where VM was created, addressType can be “vpx” or “generated”. Also note, that generatedAddress was replaced to address.

  • Save the VMX file;
  • Now return to the vCenter console, find the VM on the datastore, and add it back to the inventory by selecting VMX file and Register VM.
  • MAC address is changed:

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *