Configure Dynamic MAC addresses on a Hyper-V 2016 host

When you create a new VM on Hyper-V, which means that it will have one or more network adapters, a MAC address for each adapter is dynamically assigned at the start of the VM. This is the default behavior.

The source of the MAC addresses comes from a default MAC Address Pool of Hyper-V that you can see through the Virtual Switch Manager settings, specifically in the MAC Address Range section, as shown in the figure below.

Configure dynamic MAC addresses on a Hyper-V 2016 host

According to Microsoft documentation, the number of dynamic MAC addresses that a Hyper-V host can produce is 256. Suppose we have the MAC address aa-bb-cc-dd-ee-ff.

  • The first 3 octets (aa-bb-cc) refer to a Microsoft’s Unique Identifier that is used in all Hyper-V hosts (00: 15: 5D).
  • The next 2 octets (dd-ee) are generated by the last two octets of the IP address that was first set up on the Hyper-V server.
  • The last octet (ff) is generated from the range 0x0 – 0xFF.

Why do you have to know all this? Let’s look at it with an example.

Suppose we just installed a new Hyper-V host that took the IP address 10.10.10.10 from a DHCP server and then we set a static IP address. The dynamic MAC addresses it generates, however, depend on the first dynamic IP address it took from the DHCP Server.

This means that if we add another Hyper-V host to the infrastructure and it gets the same IP 10.10.10.10 from the DHCP Server that had the first host, then the dynamic MAC addresses it generates will be the same as the first host.

To avoid such cases, Microsoft makes it possible to change the range of dynamic MAC addresses generated by a Hyper-V host. Also, this way you can increase the limit of 256 addresses by changing the appropriate octets. This can be done using both from the GUI and from PowerShell.

By opening the Virtual Switch Manager settings and specifically in the MAC Address Range section, you can specify the range of these addresses. As the information in the box says, changing the range does not automatically change the MAC address of the already created network adapters. To get the new address, you’ll need to remove them and create them again.

For those who prefer PowerShell, the cmdlet we use in this case is Set-VMHost as shown below.

Set-VMHost -MacAddressMinimum 00155DEC6300 -MacAddressMaximum 00155DEC63FF

To see the range of dynamic MAC addresses, use the following command.

Get-VMHost | Select ComputerName, MacAddressMinimum, MacAddressMaximum | ft

An important point to note if you are going to change the Minimum and Maximum values ​​of dynamic MAC addresses is not to include in the range and static MAC addresses that you might use in some VMs.

About Dimitris Tonias 143 Articles
My name is Dimitris Tonias, IT Pro, G(r)eek, focused on Server, Virtualization, and Cloud technologies.

Be the first to comment

Leave a Reply

Your email address will not be published.


*