How to set MAC address for VM NIC on AHV cluster

  • 16 December 2023
  • 0 replies
  • 492 views

Userlevel 3
Badge +7

NIC MAC address can only be configured via acli.

  • It is not possible to change MAC address for an existing NIC. A NIC has to be deleted and then added back with the new MAC address.
  • Nutanix AHV assigns NIC MAC addresses from the range: 50:6B:8D:00:00:00 – 50:6B:8D:FF:FF:FF
  • A statically configured MAC will persist on a Protection Domain migration, but not on any clone or recover from snapshot operation

 

Run the following command on any CVM in the cluster to add a new NIC with a customized MAC address:

nutanix@CVM~$ acli vm.nic_create <vm name> network=<network name> mac=<new MAC address>

If Network name is not working or not present, we can use Network UUID from acli vm.get <VM-NAME> or acli net.list:

nutanix@CVM~$ acli vm.nic_create <vm name> network=<Network-UUID> mac=<new MAC address>

Note: “:” symbol must be used as a separator. If no separator is specified or other separator symbols are used, then the addition will fail with an “Invalid MAC address” error. This address can be outside the Nutanix range if desired

Run the following command on any CVM in cluster to check MAC address of NIC:

nutanix@CVM~$ acli vm.get <vm name>
Sample output for testvm: nutanix@CVM~$ acli vm.get testvm
testvm {
  config {

    nic_list {
      mac_addr: “aa:aa:aa:aa:aa:aa” <— custom MAC address
      network_name: “network”
      network_type: “kNativeNetwork”
      network_uuid: “37144f25-0b26-4b04-a686-976221d312c0”
      type: “kNormalNic”
      uuid: “b58b1cba-9176-4c8f-aa75-07358716f7de”
    }

  }

} VM NIC address information can be also found in Prism UI.

To delete a VM NIC, find its MAC address in the “acli vm.get <vm name>” command output and then run following command on any CVM in cluster

https://techexperience.me/2023/12/10/how-to-set-mac-address-for-vm-nic-on-ahv-cluster/

nutanix@CVM~$ acli vm.nic_delete <vm name> <NIC MAC address>

This topic has been closed for comments