25

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?

1
  • That question is better suited for serverfault/superuser.
    – Steve DL
    CommentedJun 25, 2015 at 15:46

3 Answers 3

23

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.

    12

    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...

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

    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.

      You must log in to answer this question.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.