Network settings fail for ubuntu/xenial64 Vagrant box
With the Official Ubuntu 16.04 LTS (Xenial Xerus) Vagrant box image (on VirtualBox) I have problems with basic network settings:
My 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
result:
==> 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
Leaving the configuration to DHCP also does not work:
server.vm.network "private_network", type: "dhcp"
At the same time, the above configurations work for ubuntu/trusty64
and ubuntu/wily64
and unofficial gbarbieru/xenial
.
Trying the command /sbin/ifdown eth1 2> /dev/null
gives no results as the interface has different naming scheme (the main one is enp0s3
).
Am I missing something obvious here or is the box just broken?
Solution 1:
The problem seems to be solved in the next release of vagrant: https://github.com/mitchellh/vagrant/issues/7155
I tried another box from Jeff Geerling https://twitter.com/geerlingguy/status/723571293174427648?lang=fr and it worked perfectly for me. Jeff has done a lot of great work on Vagrant/Ansible so I guess it's the best solution before the release of the next version of Vagrant
Solution 2:
Despite ubuntu/xenial64
is the Official Ubuntu box, it has some issues regarding network configuration and is not an Vagrant issue as is explained in @Maxime 's answer.
So, as in the issue is mentioned, is preferred to use a bento box (mantained by the comunity and with Opscode Chef as leader of the project), which for this case would be bento/ubuntu-16.04
.
Solution 3:
The issue is due to the network interface naming convention in new Ubuntu versions. Your Vagrant VM failed to be provisioned, but you can still ssh to it (vagrant ssh
). There you'll see that there is no interface named eth1
(you can use ifconfig -a
or ip link
). In my case, I see the interfaces enp0s3
and enp0s8
.
As mentioned in issue 6871
... we need a way to detect the interfaces instead of having a static assignment...
... or convince ubuntu to change their cloud image.
At the moment, there is no clean solution.