The virtual machine MAC address changes under Virtual PC…

MAC address management is a tricky task with virtual machines.  We need to be able to generate unique MAC addresses for each virtual machine – and try to do everything we can do to avoid MAC address conflicts.  Under Virtual Server we allow a user to specify whether their virtual machine should use static MAC addresses (managed by the user) or dynamic MAC addresses (managed by us) – but under Virtual PC we only allow for the use of dynamic MAC addresses.  What this means is that Virtual PC will generate a new MAC address for the virtual machine on the following events:

  1. When the virtual machine is created
  2. When we detect a MAC address conflict with another running virtual machine
  3. When the virtual machine is registered

The purpose of the 3rd event is so that if a user takes an existing virtual machine and copies it – they can then bring it up without having to worry about duplicate MAC addresses.  However, this can cause problems in scenarios where multiple users are sharing a physical computer and virtual machine. Each time a new user logs in and attempts to use the virtual machine, it will have to be registered and we will generate a new MAC address.  A relatively easy way to work around this problem is to create a batch file that does the following:

  1. Backs up the existing .VMC file
  2. Registers the virtual machine using ‘Virtual PC.exe -registervm’
  3. Restores the backed up .VMC file
  4. Powers on the virtual machine

This way the original MAC address will be maintained.