3

Using Vagrant, I am currently trying to set up a private_network interface on my ubuntu/precise32 box and configure this interface with a MAC address of "5C:A1:AB:1E:00:01". I have not seen an explicit example of this use anywhere as all of the examples use public network (bridged) interfaces. However the documentation shows that the :mac option is available for private network interfaces. I have tried the following combinations so far:

Syntax v1
config.vm.network :hostonly, "192.168.33.10", :mac => "5CA1AB1E0001"

Syntax v2
config.vm.network "private_network", ip: "192.168.33.11", :mac => "5CA1AB1E0001"

config.vm.network :private_network, ip: "192.168.33.11", :mac => "5CA1AB1E0001"

All three of the above lines successfully passes the Vagrant ruby parser, however none of these lines successfully change the mac address of the network adapter.

Solutions for setting mac address (syntax v1 and v2) for public (bridged) networks.

A similar question was asked here and actually works, but I can only apply it to public network setups (as shown in the answer). Specifying "private_network" in place of public network successfully launched the VM, but fails to change the mac address of the private interface (eth1).

Community
  • 1
  • 1
Phil
  • 401
  • 8
  • 18

2 Answers2

6

I used vboxmanage to modify the MAC address. I didn't know it could be changed with Vagrant's syntax. More on vboxmanage.

config.vm.provider "virtualbox" do |vb|
  vb.customize ["modifyvm", :id, "--macaddress1", "5CA1AB1E0001" ]
end
IT Jen
  • 61
  • 1
  • 2
  • this is exactly what I was looking for! Vagrant uses the same MAC for all of the guests created off the same box file, causing all kinds of issues if one of the boxes is promoted to a Domain Controller. – mr.buttons Jan 30 '15 at 16:30
5

Requires Patch

This was a bug in the VirtualBox provider for vagrant. See issue #3588 for details. The syntax described in the above question is correct as I have built vagrant from the gitub master branch and tested myself.

Configuration I used (syntax v2)

config.vm.network "private_network", ip: "192.168.33.11", :mac => "5CA1AB1E0001"
Phil
  • 401
  • 8
  • 18
  • Setting my own response to the "correct" answer to this question. This should really only serve as a reference to the issue filed and fixed by the Vagrant community. The syntax mentioned both in the question and this answer are indeed valid and recommended usage. – Phil Aug 30 '16 at 23:36
  • 1
    Worked for me running Vagrant 1.8.1, using provider Virtual Box 5.0.x. – MikeyE Jan 26 '17 at 19:14