【问题标题】:vagrant up fails for bento/ubuntu-16.04 on Oracle VirtualBox 5.0.16 r105871Oracle VirtualBox 5.0.16 r105871 上的 Bento/ubuntu-16.04 的 vagrant up 失败
【发布时间】:2017-01-11 23:58:49
【问题描述】:

今天我打算使用 vagrant 将最新的 Ubuntu 版本放入我的虚拟盒子中。加载镜像并运行vagrant up后,出现如下报错,与虚拟盒子的网络配置有关。

有趣的是,网上已经有一些帖子(主要在 GitHub 上,例如:https://github.com/mitchellh/vagrant/issues/7155),还有 AskUbuntu (https://askubuntu.com/questions/760871/network-settings-fail-for-ubuntu-xenial64-vagrant-box)、StackOverflow (vagrant up command giving error and eth1 not showing a resolvable ip address) 和 StackExchange (https://unix.stackexchange.com/questions/188413/not-able-to-resolve-ip-address-for-eth1-in-vagrant-vm)。但是,这些问题与 xenial64(即 not bento)或使用 public_network 配置有关。

正如https://askubuntu.com/questions/760871/network-settings-fail-for-ubuntu-xenial64-vagrant-box 中所报告的,ubuntu/trusty64ubuntu/wily64 不存在此问题,但似乎ubuntu/xenial64bento/ubuntu-16.04 都存在此问题(即两个Ubuntu 16 机器)。

正如您将在下面的Vagrantfile 中看到的,我对bento/ubuntu-16.04 进行了简单设置,并且仅使用private_network。需要明确的是,我不能真正使用这篇文章 (vagrant up command giving error and eth1 not showing a resolvable ip address),因为它建议注释掉 vagrant 配置的 public_network 部分。另外,我应该提到在发生此错误时没有其他 VM 正在运行。

从错误日志看来,netowrk 接口eth1 似乎很明显存在问题,但究竟是什么问题,我不清楚。之前我已经成功启动hashicorp/precise32ubuntu/trusty64的Ubuntu盒子,同样的vagrant配置和同样的Oracle VB,没有遇到过这个问题。

感谢任何帮助。下面列出了我的技术设置和参考文件。

干杯 AHL


设置:

流浪文件:

Vagrant.configure(2) do |config|

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

  config.vm.network "private_network", ip: "192.168.33.10"

end

输出:

C:\Users\AHL\workspace>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/ubuntu-16.04' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
GuestAdditions 5.0.16 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ifdown eth1 2> /dev/null

Stdout from the command:



Stderr from the command:

mesg: ttyname failed: Inappropriate ioctl for device

C:\Users\AHL\workspace>

【问题讨论】:

    标签: vagrant ubuntu-16.04 bento


    【解决方案1】:

    我遇到了问题,发现由于某种原因,虚拟盒子没有将虚拟电缆连接到网络接口。

    我通过添加解决了它

        vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
    

    到我的config.vm.provider "virtualbox" do |vb| 循环,例如在我的情况下,我想要连接 1GB RAM、USB3 和网络电缆:

    config.vm.provider "virtualbox" do |vb|
        vb.memory = "1024"
        vb.customize ["modifyvm", :id, "--usbxhci", "on"]               # Connect USB3 disk
        vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
    end
    

    在我使用过的任何其他框中,我不需要此 --cableconnected1 行,仅在 config.vm.box = "bento/ubuntu-16.04" 中。

    也许你必须检查vagrant up是否没有连接你的任何电缆,我还有一个额外的网络,eth0 未连接,eth1 已连接。

    检查您的具体情况。可能你得玩一下选项后面的数字。

    希望这会有所帮助!

    【讨论】:

    • 谢谢,这个修复拯救了一天。只需添加 --cableconnected1 行对我有用
    【解决方案2】:

    我认为在你的列表中,你需要添加https://github.com/mitchellh/vagrant/issues/6871

    问题仍然存在 - 一些用户报告他们可以解决问题(https://github.com/mitchellh/vagrant/issues/6871#issuecomment-223290622https://github.com/mitchellh/vagrant/issues/6871#issuecomment-222348226

    如果您可以使用 packer 自己构建您的盒子,有一些网络问题的修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-18
      • 2016-03-30
      • 2015-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多