1

Today I was planning to get the latest Ubuntu release into my virtual box using vagrant. After loading the image and running vagrant up, I got an error as reported below, which relates to the network configuration of the virtual box.

Interestingly, there are already some posts online (mainly on GitHub, e.g.: https://github.com/mitchellh/vagrant/issues/7155), but also on 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) and StackExchange (https://unix.stackexchange.com/questions/188413/not-able-to-resolve-ip-address-for-eth1-in-vagrant-vm). However these issues relate to either xenial64 (i.e. not bento) or use a public_network configuration.

As reported in https://askubuntu.com/questions/760871/network-settings-fail-for-ubuntu-xenial64-vagrant-box, this issue does not exist for ubuntu/trusty64 or ubuntu/wily64, but seems to be an issue for both ubuntu/xenial64 and bento/ubuntu-16.04 (i.e. both Ubuntu 16 boxes).

As you will see in my Vagrantfile below, I have a simple setup for bento/ubuntu-16.04 and use private_network only. To be clear, I can't really use this post (vagrant up command giving error and eth1 not showing a resolvable ip address) since it suggests to comment out the public_network part of the vagrant configuration. Also, I should mention that there are no other VM's running at the time this error occurs.

From the error log it seems obvious that there is an issue with the netowrk interface eth1, but what exactly the problem is, is unclear to me. I have previously successfully started the hashicorp/precise32 and ubuntu/trusty64 Ubuntu boxes with the same vagrant configuration and the same Oracle VB and have not encountered this problem.

Any help is appreciated. My technical setup and reference files are listed below.

Cheers AHL


Setup:

Vagrantfile:

Vagrant.configure(2) do |config|

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

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

end

Output:

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>
Community
  • 1
  • 1
AHL
  • 738
  • 3
  • 11
  • 35

2 Answers2

6

I had the problem and found that for some reason, the virtual box did not connect the virtual cable to the network interface.

I solved it by adding

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

to my config.vm.provider "virtualbox" do |vb| loop, for example in my case I wanted 1GB RAM, USB3 and the network cable connected:

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

I did not need this --cableconnected1 line in any other boxes I have used, only in config.vm.box = "bento/ubuntu-16.04".

Maybe you have to check if doing vagrant updoes not connect any of your cables, I had also an extra network and eth0 was unwired and eth1 was wired.

Check your particular case. Maybe you have to play with the number after the option.

Hope this helps!

Xavi Montero
  • 9,239
  • 7
  • 57
  • 79
  • 1
    thank you, this fix saved the day. Just adding the `--cableconnected1` line worked for me – yvoyer Oct 30 '17 at 17:06
2

I think in your list, you need to add https://github.com/mitchellh/vagrant/issues/6871

The issue is still open - There are some users who reported they could fix the issue (https://github.com/mitchellh/vagrant/issues/6871#issuecomment-223290622 or https://github.com/mitchellh/vagrant/issues/6871#issuecomment-222348226)

If you can build your box yourself using packer, there are some fixes on the network issue.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139