2

I'm not sure if this is entirely possible so thought it was worth asking. I would like to use Vagrant to allow users to spin up a VM when needed. However, on our network devices must be registered via their MAC address. Creating a pool of addresses is not an issue but is it possible to select an address for a VM i.e. in a step by step procedure:

  1. Read file of MAC addresses
  2. Select MAC address that is not being used
  3. Spin up VM and set MAC address

Hoping someone can shed some light on this as my googling has failed me.

Benjamin
  • 250
  • 2
  • 9
Matt John
  • 33
  • 3

2 Answers2

2

I believe this is possible, as vagrant configuration is generated by executing a Ruby file; by using the standard ruby libraries you could examine the file, select an unused MAC and spin up the VM as you describe, by plugging the retrieved value into the configuration directive here.

However I would recommend that if the VMs will be spun up on different Users' hosts then rather than using a file, it may be better to provide a web service that can give the vagrant configuration an unused mac address, centrally managing the pool of addresses that are considered used or not.

You could then use something like the functionality provided here to inform your web service that the mac address is no longer being used on vagrant halt or vagrant destroy

Benjamin
  • 250
  • 2
  • 9
  • That's exactly what I wanted. Providing a web interface is the next stage of development after I get the initial spinning up and chef configuration working. Thanks! – Matt John Aug 06 '15 at 08:08
1

All of VMWare's automatic MAC addresses fall within 00:50:56:00:00:00-00:50:56:3F:FF:FF - why not just predefine that range? Yes it's 262,143 addresses but it's not that big.

Chopper3
  • 101,299
  • 9
  • 108
  • 239