Vagrant Multibox - 我的网络适配器未被识别

Vagrant Multibox - my network adapter is not being recognised

我有一个问题,我试图为我的 Vagrantfile 分配一个 public_network 接口我有正确的适配器 selected,但每次我 运行 vagrant up 它要求我 select 适配器。

我在文件中设置的适配器在列表中

web.vm.network "public_network", bridge: "en4: Display Ethernet"

我不知道为什么我这样设置时它要求我选择一个适配器。

这是我的 Vagrantfile,下面是终端输出的图像:

Vagrant.configure("2") do |config|

config.vm.box = "bento/ubuntu-16.04"

config.vm.define "web01" do |web|
    web.vm.network "private_network", ip: "192.168.50.3"
    web.vm.network "forwarded_port", guest: 80, host: 8093
    web.vm.network "public_network", bridge: "en4: Display Ethernet"
    web.vm.network "public_network", ip: "192.168.2.230"
    #web.vm.provision :shell, path: "bootstrap.sh"    

    web.vm.provider "virtualbox" do |vb|
        vb.gui = false
        vb.name = "16.04-web01"
        vb.memory = "512"
    end
end

config.vm.define :sql01 do |sql|
    sql.vm.network "private_network", ip: "192.168.50.2"
    sql.vm.network "forwarded_port", guest: 80, host: 8094
    sql.vm.network "public_network", bridge: "en4: Display Ethernet"
    sql.vm.network "public_network", ip: "192.168.2.231"
    #sql.vm.provision :shell, path: "bootstrap.sh"
    sql.vm.provision :shell, path: "installsql.sh"    

    sql.vm.provider "virtualbox" do |vb|
        vb.gui = false
        vb.name = "16.04-sqlserver"
        vb.memory = "4096"
    end
end

#Options for Me specific
#config.vm.synced_folder "/Applications/MAMP/htdocs/", "/htdocs_home"

end

您正在使用相同类型 :public_network 但参数不同的方式调用 config.vm.network method 两次。第二个调用似乎覆盖了第一个调用执行的设置,即使代码建议应该合并设置。

替换:

web.vm.network "public_network", bridge: "en4: Display Ethernet"
web.vm.network "public_network", ip: "192.168.2.230"

单行:

web.vm.network "public_network", ip: "192.168.2.230",  bridge: "en4: Display Ethernet"