How MAC Addresses Are Assigned in Virtual Machines and Containers

Enterprise networks

Every virtual adapter in a virtualised environment needs a MAC address. Each platform uses its own registered OUI prefix, so entering a VM address on the lookup page often tells you straight away which platform it runs on, which is handy when untangling a mixed environment.

Prefixes by platform

PlatformCommon prefixNotes
VMware00:50:56Manually assigned or allocated by vCenter
VMware00:0C:29Generated automatically by ESXi
VMware00:05:69Used by older versions
Microsoft Hyper-V00:15:5DCovers both dynamic and static
VirtualBox08:00:27Registered to Oracle
Xen00:16:3E
Parallels00:1C:42
QEMU / KVM52:54:00Note this is a locally administered address

The last entry deserves attention. The first byte of 52:54:00 is 0x52, binary 01010010, whose second least significant bit is set, making it a locally administered address. Strictly speaking it is not an IEEE-allocated OUI. Because QEMU is so widely deployed, many databases include it as a special case anyway. The same flag-bit reasoning appears in reading the first byte of a MAC address.

Container networking

Docker's default bridge network gives each container a random MAC, usually with the prefix 02:42:AC. A leading 02 is again locally administered, and 42:AC plus the last two octets of the container IP form the rest. In other words a Docker container's MAC is derived from its IP, which guarantees no collisions inside one subnet.

Behaviour differs with the macvlan and ipvlan drivers, where containers appear directly on the physical network and the address can be set explicitly:

docker run --mac-address 02:42:ac:11:00:02 ...

Kubernetes depends on the CNI plugin. Calico, Flannel and Cilium each allocate differently, though most stay inside the locally administered range.

Setting one by hand

KVM and libvirt specify it in the domain XML:

<interface type='bridge'>
  <mac address='52:54:00:12:34:56'/>
  <source bridge='br0'/>
</interface>

VMware manual assignments should fall inside 00:50:56, with the last three bytes clear of the range vCenter allocates automatically, or collisions become possible.

VirtualBox:

VBoxManage modifyvm "vm-name" --macaddress1 080027123456

Cloning is the main source of conflicts

Copy a VM image or disk file directly and the new machine boots with the original MAC. Running both at once produces an address conflict, which shows up as intermittent loss of connectivity on both sides and takes a long time to diagnose.

Every platform offers an option to regenerate the address, and when cloning you should always choose to generate a new MAC rather than preserve the existing configuration. Linux adds one more trap: /etc/udev/rules.d/70-persistent-net.rules or a NetworkManager connection profile may still record the old address, so the new machine's adapter is renamed to eth1 while the configuration stays bound to eth0 and networking never comes up. Clearing those files after cloning is a standard step.

What it means for network operations

Leave headroom in port security. A host running a dozen VMs in bridged mode presents a dozen MACs on one switch port. Limiting that port to one under port security takes every VM on the host offline. Set a sensible cap on virtualisation host ports, or none at all.

Separate physical from virtual in inventory. The prefix allows automatic classification, which is a practical rule when using MAC addresses for inventory.

Re-estimate DHCP pool capacity. Virtual machines usually outnumber physical ones, and rapid create-and-destroy cycles consume lease entries. Related caveats are in how DHCP uses MAC addresses.

Related Articles
About the Author · Kai

7n4.cn author focused on network operations, including switches, access points, and wireless controllers. The articles follow practical checks that readers can reproduce.

← Back to Blog