ubuntu / xenial64 Vagrant框的网络设置失败
使用官方Ubuntu 16.04 LTS(Xenial Xerus) Vagrant盒子图像(在VirtualBox上)我遇到基本网络设置问题:
我的Vagrantfile
:
Vagrant.configure(2) do |config| config.vm.box = 'ubuntu/xenial64' config.vm.define "xenial" do |server| server.vm.network "private_network", ip: "192.168.10.10" end end
vagrant up
结果:
==> xenial: 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: sudo: unable to resolve host ubuntu-xenial mesg: ttyname failed: Inappropriate ioctl for device
将配置保留为DHCP也不起作用:
server.vm.network "private_network", type: "dhcp"
同时,上述配置适用于ubuntu/trusty64
和ubuntu/wily64
以及非官方gbarbieru/xenial
。
尝试命令/sbin/ifdown eth1 2> /dev/null
没有结果,因为接口有不同的命名方案(主要的是enp0s3
)。
我错过了这里显而易见的东西,还是盒子坏了?
这个问题似乎在下一个流浪者版本中得到解决: https : //github.com/mitchellh/vagrant/issues/7155
我尝试了Jeff Geerling的另一个盒子https://twitter.com/geerlingguy/status/723571293174427648?lang=fr ,它对我来说非常适合。 Jeff在Vagrant / Ansible上做了很多很棒的工作,所以我想这是在下一版Vagrant发布之前的最佳解决方案
尽管ubuntu/xenial64
是官方的Ubuntu框,但它有一些关于网络配置的问题,并且不像@Maxime的回答中所解释的那样是一个流浪问题。
因此,正如在提到的问题中,最好使用便当盒(由社区和Opscode Chef作为项目的负责人),在这种情况下将是bento/ubuntu-16.04
。
问题是由于新的Ubuntu版本中的网络接口命名约定。 您的Vagrant VM无法配置,但您仍然可以使用它( vagrant ssh
)。 在那里你会看到没有名为eth1
接口(你可以使用ifconfig -a
或ip link
)。 在我的例子中,我看到接口enp0s3
和enp0s8
。
如问题6871中所述
…我们需要一种方法来检测接口而不是静态分配……
…或说服ubuntu改变他们的云形象。
目前,没有干净的解决方案。
实际上,除了Maximes的答案,您可以更改框中的GRUB命令行,直到新版本传播。
只需转到/etc/default/grub
并将相应的行设置为GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
您必须更改/etc/network/interfaces
以反映正确的名称(eth0 …)。
有关详细信息,请参阅certdepot中的文档 。
我遇到了原始问题中讨论的类似问题。
我正在使用Vagrant 1.8.1。 并且使用ubuntu / trusty64框工作得很好,但是,当我尝试使用ubuntu / xenial64框时,我遇到了同样的问题。 这个问题线程中的评论让我得到了一个解决方案,这似乎有用。
我换了线
config.vm.network "private_network", ip: "192.168.33.10"
在Vagrantfile中
config.vm.network "private_network", ip: "192.168.33.10", auto_config: false