Vagrant Virtualbox覆盖默认网络接口

时间:2015-02-03 17:41:07

标签: macos vagrant virtualbox vagrantfile

我想覆盖"适配器1"并将其从默认NAT更改为Bridged。

这是使用VirtualBox的MacOSX

我的无耻尝试如下:

NODE_COUNT = 5
NODE_COUNT.times do |i|
    node_id = "mes00#{i += 1}"
    config.vm.define node_id do |node|

    # $network_interface could either be en0 or en1 depending in which is up
    node.vm.network :public_network,  :type => "dhcp",:bridge =>     $network_interface,:interface => 1
    node.vm.network :private_network, :ip => "192.168.0.1#{i}",:interface => 2
    node.vm.box = "ubuntu/trusty64"
    node.vm.hostname = "#{node_id}"
  end
end

输出显示:

==> mes004: Preparing network interfaces based on configuration...        
mes004: Adapter 1: nat
mes004: Adapter 2: bridged
mes004: Adapter 3: hostonly

1 个答案:

答案 0 :(得分:1)

至于流浪汉,第一个nic总是nat。是设计的。

如果您分享您面临的问题,可能是所有问题的解决方法。