When should a VM have a static MAC address?

In most cases, administrators don't have to worry about a VM's MAC addresses, but sometimes setting a static address is the only way to avoid conflicts.

In the physical world, each network adapter has an associated Media Access Control address that identifies the device on the physical network. In the virtual world, it is easy to forget all about MAC addresses. After all, VMs use virtual network adapters and these virtual network adapters typically piggyback off of a physical network adapter. As such, it is easy to assume that the virtual network adapter inherits, or at least uses the physical network adapter's MAC address. However, virtual network adapters typically receive their own dedicated MAC address. The question is however, why does this even matter?

From a logistical -- but not necessarily a practical -- standpoint, assigning a dedicated MAC address to virtual network adapters is important because of VM portability. If a VM simply inherited the host's MAC address then the VM's MAC address would change every time the VM was migrated from one host to another. Depending on the hypervisor used and the way in which the VM is configured, it is possible that migrating a VM from one host to another could potentially result in a MAC address change in some circumstances. As a general rule however, a static MAC address is a VM attribute that remains in effect as the VM is moved from one host to another. Once again, one has to consider why this matters.

There are two main reasons why VM MAC addresses matter. First, many network inventory tools are designed to identify network endpoints -- including VMs -- by MAC address. Sure, there are other attributes that could potentially be used to identify a server, but MAC addresses are often used because they tend to be more static than other identifying attributes such as IP addresses.

Another reason why VM MAC addresses matter is because they open the door to "bare metal" VM management. Admittedly, this concept sounds ridiculous on the surface, but bare-metal VM management does have its place, especially when it comes to VM provisioning.

From a logistical -- but not necessarily a practical -- standpoint, assigning a dedicated MAC address to virtual network adapters is important because of VM portability.

The major hypervisor vendors provide tools that can be used to create VMs from prebuilt template images. Microsoft, for example, enables template-based VM creation through System Center Virtual Machine Manager. The problem is there is a cost associated with this process.

If an organization is still using a legacy provisioning tool designed for physical servers, it may sometimes be possible to use such a tool to provision virtual servers. I recently assisted one organization with such a project. The software this particular organization was using required the administrator to specify the MAC address for the server that was to be provisioned. The specified server could then perform a PXE boot that would connect it to the provisioning software and begin the process of installing the operating system. Although this software predated modern hypervisors, I was able to make it work for VM provisioning by taking control of the VM's MAC address.

Even if an organization does not depend on third-party inventory, monitoring or provisioning software, it may still be necessary to assign a static MAC address to a VM. VMware ESXi for example, limits each host server to assigning 256 MAC addresses to the VMs residing on the host. Without a workaround, this limit would affect the total number of VMs that can be created on a host -- or more precisely, the total number of virtual NICs. Fortunately, VMware allows customers to circumvent this limitation by manually assigning a static MAC address to VMs.

Of course this raises the question of how an administrator can either assign or determine a VM's MAC address without the aid of a guest operating system. The technique varies from one hypervisor to the next. In Windows Server 2012 R2 Hyper-V, you can assign a static MAC address by opening the Hyper-V Manager, right clicking on the VM and selecting the "Settings" command from the shortcut menu. Upon doing so, you will see the VM's settings window, which displays all of the VM's virtual hardware. Expand the "Network Adapter" container and click on the "Advanced Features" container. This will display the option to assign a static MAC address, as shown in Figure A.

Microsoft Hyper-V allows an administrator to assign a static MAC address to a VM's virtual network adapter.
Hyper-V allows you to assign a static MAC address to a virtual network adapter.

Although VM MAC addresses probably aren't something you configure on a daily basis, static MAC addresses for VMs do have their place. Knowing how to manually assign a static MAC address can make it easier to adapt a VM for use with software designed for the physical world, and may even allow you to overcome hypervisor level limitations.

Next Steps

Hyper-V MAC address conflicts

How to change a Hyper-V VM MAC address

Monitoring network traffic in a VMware environment

Dig Deeper on Virtual machine provisioning and configuration