Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dhcp private_network fails on virtualbox #3083

Closed
phinze opened this issue Mar 8, 2014 · 77 comments
Closed

dhcp private_network fails on virtualbox #3083

phinze opened this issue Mar 8, 2014 · 77 comments

Comments

@phinze
Copy link
Contributor

phinze commented Mar 8, 2014

Problem

With a fresh VirtualBox install, adding a private network with type: :dhcp fails with the following error:

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["dhcpserver", "add", "--ifname", "vboxnet0", "--ip", "172.28.128.2", "--netmask", "255.255.255.0", "--lowerip", "172.28.128.3", "--upperip", "172.28.128.254", "--enable"]

Stderr: VBoxManage: error: DHCP server already exists

Subsequent boots fail with a different message:

A host only network interface you're attempting to configure via DHCP
already has a conflicting host only adapter with DHCP enabled. The
DHCP on this adapter is incompatible with the DHCP settings. Two
host only network interfaces are not allowed to overlap, and each
host only network interface can have only one DHCP server. Please
reconfigure your host only network or remove the virtual machine
using the other host only network.

Steps to repro

Fresh install of Vagrant 1.4.3 and VirtualBox 4.3.6.

Minimal Vagrantfile:

# force virtualbox provider
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'

Vagrant.configure('2') do |config|
  config.vm.box     = 'precise64'
  config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
  config.vm.network 'private_network', type: :dhcp
end

Error message will appear on first vagrant up. My test host is OS X but I bet you this occurs on all hosts.

Explanation

VirtualBox ships with an initial dhcpserver seeded in its config [1].

$ VBoxManage list dhcpservers
NetworkName:    HostInterfaceNetworking-vboxnet0
IP:             192.168.56.100
NetworkMask:    255.255.255.0
lowerIPAddress: 192.168.56.101
upperIPAddress: 192.168.56.254
Enabled:        Yes

The hostonlyifs settings ship empty.

When encountering a private network with type: :dhcp, Vagrant sees this HostInterfaceNetworking-vboxnet0 dhcpserver and assumes that it is valid and ready to be attached to vboxnet0. But vboxnet0 was just created and has an IP address of 172.28.128.1.

So the error message comes from VirtualBox yelling that you can't assign a dhcpserver with an IP address outside the network of an adapter.

But the error occurs after the hostonlyif has been created, so it's leaked to subsequent boots, which is why the error message changes.

What now?

We have a couple of options to solve this:

  1. Petition VirtualBox to ship with an empty dhcpservers config
  2. Add code to Vagrant to clean up this default dhcpserver
  3. Add code to Vagrant to get smarter about dhcpservers with inconsistent IP addresses, possibly suggesting action to the user to fix

Workaround

Removing the default dhcpserver from VirtualBox solves all these collision problems.

VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0

[1] Here's the code that seeds the dhcpserver: https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Main/xml/Settings.cpp#L1506

@bchavet
Copy link

bchavet commented Mar 19, 2014

The workaround that I am using is to run the following before the first vagrant up

VBoxManage hostonlyif create

If this is a fresh VirtualBox installation, this creates a new vboxnet0 interface that gets the default dhcp server linked, and Vagrant can proceed with creating its own at vboxnet1. If this is an already-primed VirtualBox installation, this will just result in an extra, unused interface. This is a pretty minor side effect until a more graceful solution can be worked out.

@AdamKalnas
Copy link

Thanks for posting this, it helped me get what I needed to get vagrant setup on Ubuntu 14.04.

FWIW.. this did not work for me

VBoxManage hostonlyif create

While this did work 👍

VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0

@mitchellh
Copy link
Contributor

Closing due to inactivity. Still a bug but its one I never hear about (I think only if DHCP is used?) and seems pretty low priority.

@tmm1
Copy link

tmm1 commented Jun 3, 2014

Ran into this as well and the VBoxManage dhcpserver remove trick worked. If a proper fix is not planned, perhaps the command (or a link to this issue) could be added to the lengthy message vagrant spits up when the error is encountered.

@YmerejRedienhcs
Copy link

I experienced this too. I didn't explicitly choose DHCP, I just did a default install of virtualbox on my OSX machine. I agree: if you're not going to fix it, it would be nice for you to document the workaround in the error message. As for priority, it stopped my vagrant deployment from working. To me, who is affected by it, that's higher than "pretty low priority".

@jwieringa
Copy link

A default installation of Vagrant 1.6.3 and VirtualBox 4.3.12 resulted in this error for me too. A link to this issue would work for me.

The following command resolved the issue for me:

VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0

👍 for all for the help.

@ThomWright
Copy link

I had this issue today, I agree with @YmerejRedienhcs - what would it take for this to become higher priority than "pretty low"?

@rjmunro
Copy link

rjmunro commented Jun 27, 2014

Please increase priority of this. It happens on a basic new installation, it's going to break for all new developers / designers etc. on my projects.

I found the suggested workaround fixed it for me:

VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0

@lxcodes
Copy link

lxcodes commented Jul 9, 2014

The VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0 command worked for me as well. +1.

@Magrath
Copy link

Magrath commented Jul 11, 2014

+1

4 similar comments
@jwhitcraft
Copy link

+1

@jmvrbanac
Copy link

+1

@ms-tg
Copy link

ms-tg commented Jul 30, 2014

👍

@kensykora
Copy link

+1

@tclift
Copy link

tclift commented Aug 4, 2014

+1 - bit me, found this issue, command fixed

@pagojo
Copy link

pagojo commented Aug 18, 2014

This seems pretty basic functionality which needs to be in the command line and at least in the documentation I think. Thanks for the good work btw :-)

@vladcosorg
Copy link

also encountered this bug
the command fixed it

@minonne
Copy link

minonne commented Aug 26, 2014

+1

@phinze
Copy link
Contributor Author

phinze commented Aug 26, 2014

Hey folks! Filed https://www.virtualbox.org/ticket/13323 upstream, we'll see what uncle VBox has to say! 👴

@dchesterman
Copy link

This happened with me with the default Vagrantfile create from Berkshelf.

@jolankester
Copy link

+1 @rjmunro

@rsrchboy
Copy link

+1 -- frustrating couple days spent hunting down what was actually going on.

@juanbrujo
Copy link

VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0 👍 👍 👍

@bramswenson
Copy link

I'm surprised that this is still an issue. However, on the latest ubuntu vivid with virtualbox installed from the oracle repo, it is. The VBoxManage command above removing the interface settings worked.

@thoughtarray
Copy link

+1

@jbradley428
Copy link

+1

@f1337
Copy link

f1337 commented May 27, 2015

+1 just happened to me using Vagrant on a Yosemite host (10.10.3) w/ an Ubuntu (14.04) guest. I have been using Vagrant for over a year with RHEL, CentOS, Oracle Linux and Ubuntu 13.x guest OSes, and no issues with any of those.

UPDATE: I used the box-cutter/ubuntu1404-desktop base box when I got the error. Have not tested if a custom Ubuntu 14.04 base box fixes the issue.

VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0 "worked" to unblock me.

@okor
Copy link

okor commented Jun 2, 2015

Vagrant noob here, definitely still an issue. VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0 worked for me on OSx Yosemite

@hanmd82
Copy link

hanmd82 commented Jun 16, 2015

+1 to this solution: VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0

Based off a fresh install of Vagrant 1.7.2 and VirtualBox 4.3.28

@mpermar
Copy link

mpermar commented Jun 19, 2015

+1 fresh vagrant fresh VB

@ibawolf
Copy link

ibawolf commented Sep 16, 2015

+1
Thanks for this solution VBoxManage dhcpserver remove
fresh install of Vagrant 1.7.4 and VirtualBox 5.0.4 on Ubuntu 14.04.

@mightydok
Copy link

Same error, fresh install of Vagrant 1.7.4 and VirtualBox 4.3

@dtr0yan
Copy link

dtr0yan commented Dec 1, 2015

+1 for vbox 5.0.10 and vagrant 1.7.4 on Ubuntu 14.04

@abacaj
Copy link

abacaj commented Dec 8, 2015

+1 vagrant 1.7.4 - on windows I had to manually remove it from virtualbox under file -> Preferences -> Network -> Host-only Networks highlight the available network and click the minus sign to remove it.

@shatil
Copy link

shatil commented Oct 10, 2016

+1

Still a problem for me. Now that I know about it I won't lose another half hour setting up a VirtualMachine using https://github.com/chef/bento and http://berkshelf.com.

@harmittaa
Copy link

Same error, Windows 10, Vagrant 1.9.1, VirtualBox 5.1.14. Fixed by deleting the Host-only Networks from the VirtualBox GUI. Just to note, I happened to have two of them for some reason.

@PortWhisperer
Copy link

PortWhisperer commented Jun 11, 2017

Just got this error on Vagrant 1.9.1 vbox 5.1.22

@ggeldenhuis
Copy link

This issue still appears to be very much broken unfortunately.

@rnwolfe
Copy link

rnwolfe commented Jul 1, 2018

Issue definitely still exists. Vagrant 2.1.2 and VirtualBox 5.2.12.

Agree with people above that this should not be an out-of-the-box error that is likely to occur for any host-only network using DHCP (which is default for VirtualBox).

@mmatela
Copy link

mmatela commented Jun 17, 2019

If the VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0 comand gives you error: VBoxManage.exe: error: DHCP server does not exist
then you can use the VBoxManage list dhcpservers command to see available servers. It worked for me to remove them all (by NetworkName).

@CapSel
Copy link

CapSel commented Dec 16, 2019

Just upgraded VirtualBox and Vagrant and had the very same problem.

@d-vb
Copy link

d-vb commented Dec 18, 2019

Same here.

@ARehmanMahi
Copy link

Freaking 5 year old issue still persist, smh.

@LukeCarrier
Copy link

LukeCarrier commented Jan 20, 2020 via email

@sirus20x6
Copy link

My work is suffering from this. I need to be able to use virtual box.

@ghost
Copy link

ghost commented Jan 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests