Vagrant Virtualbox 覆盖默认网络接口



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

这是使用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

至于流浪者,第一个 NIC 总是 nat。

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

最新更新