18

As I understand it, MAC addresses are assigned to every physical device by the manufacturer. By extension, how are MAC addresses assigned to virtual machines - for example if I create a new virtual machine with an ISO of linux assigned?

If it is assigned during creating a new virtual machine - don't we run the risk of having a MAC address assigned that is already in use?

migrated from security.stackexchange.com Jun 25 '15 at 16:57

This question came from our site for information security professionals.

  • That question is better suited for serverfault/superuser. – Steve DL Jun 25 '15 at 15:46
17

Yes, the MAC address ranges that are used by virtual machines all over the world are reused.

However, MAC addresses only need to be unique on the local layer 2 network. Anything on the other side of a router doesn't know or care what your local MAC addresses are. Only devices that are connected directly or through switches know each other's MAC addresses.

Inside your network, MAC address conflicts can be a problem. Most hypervisors allow you to set what range of MAC addresses they automatically assign to new virtual machines, so if you have several hosts, you configure them to each use a different range. Care must also be taken to ensure a new MAC address is generated when cloning a virtual machine.

11

how are MAC addresses assigned to virtual machines

They're made up. Oh, not completely; they use specific OUIs (the first 3 octets, sometimes called a vendor ID) to not conflict with known hardware vendors. But they're generated locally, there's no central database or anything like that.

If it is assigned during creating a new virtual machine - don't we run the risk of having a MAC address assigned that is already in use?

Yes, but the risk is pretty low. The OUI should be separate from non-VM devices. Even if we take two VM hosts assigning from the same OUI, there are 2^24 possible choices, or 16777216 possible MAC addresses. Since MAC only matters on the local network, those are generally good odds...

  • To put that in perspective, the probability of a collision is only about 3% when you have 1000 VMs. wolframalpha.com/input/… – Ajedi32 Jun 25 '15 at 13:48
  • …or, similar to those of winning the lottery ;) – Tetsujin Jun 25 '15 at 17:39
2

Typically, the virtualization platform will generate a new, random MAC address for each virtual network interface at creation (depending on the software, you might override that random MAC with one of your chosing).

In the context of ethernet, a MAC addresses only have to be unique on a specific network segment to work so it's actually quite simple to generate statistically unique MACs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.