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

有帮助吗?

解决方案 2

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"

其他提示

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top