dhcp private_network fails on virtualbox
phinze opened this issue ยท 77 comments
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:
- Petition VirtualBox to ship with an empty
dhcpservers
config - Add code to Vagrant to clean up this default dhcpserver
- 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
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.
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
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.
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.
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".
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.
I had this issue today, I agree with @YmerejRedienhcs - what would it take for this to become higher priority than "pretty low"?
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
The VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
command worked for me as well. +1.
+1
+1
+1
๐
+1
+1 - bit me, found this issue, command fixed
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 :-)
also encountered this bug
the command fixed it
+1
Hey folks! Filed https://www.virtualbox.org/ticket/13323 upstream, we'll see what uncle VBox has to say! ๐ด
This happened with me with the default Vagrantfile create from Berkshelf.
+1 @rjmunro
+1 -- frustrating couple days spent hunting down what was actually going on.
+1
Vagrant should not be in a broken state when you first try to use it (if the Vagrantfile uses :private_network, type: dhcp).
This is just my opinion, but Vagrant should either support the feature or disable it, having to use esoteric workarounds to get going makes Vagrant look bad.
+1
๐ We just ran into this at the office. Unsure how it started (I've never seen it happen), but my colleague just had this issue. Using VBoxManage ... remove ...
solved the issue.
+1
+1
+1
+1
+1
+1
+1
Alrighty dear peoples - we finally have a candidate fix in the pipeline over at #4882 - stay tuned for reviews and eventual mergings! ๐ต
+1
@jasonm-makerbot the fix for this was merged - are you still hitting this on latest vagrant?
I just ran into this issue on 1.7.1 (The latest version as of today). This is a brand new mac, and this was the first vagrant machine I've ever tried to start on this machine.
Going into the Virtualbox gui and deleting the Host-Only Network fixed the problem for me. I guess Virtualbox ships with a Host-Only Network by default.
Dang, the detection code in 25ff636 must not be triggering. ๐ I'll reopen for now and take a look soon.
I also still see this in 1.7.1, on a brand new RHEL box with fresh virtualbox + vagrant 1.7.1 install. Work-around VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
worked still. Let me know if you need help testing potential fixes.
@phinze I did a bit more digging and it looks like the VirtualBox global settings are stored on a per user basis in the user's home folder ~/.config/VirtualBox.
So if you run VBoxManage dhcpserver remove ...
as root, and you install/run vagrant as root, there is no issue, I suspect your fix will work.
However if vagrant gets installed as root (and root's DHCP server gets removed), but a non-root user tries to run vagrant up
, he will run into the issue because the DHCP server exists for him (his ~/.config/VirtualBox/ folder is completely different).
Could this be the issue?
Yes I am on the latest version of Vagrant:
jason.meredith@JasonMeredithMBP:[Preferences] $ vagrant --version
Vagrant 1.7.1
On Jan 5, 2015, at 6:09 PM, Paul Hinze notifications@github.com wrote:
@jasonm-makerbot the fix for this was merged - are you still hitting this on latest vagrant?
โ
Reply to this email directly or view it on GitHub.
NOTICE: This email may contain information that is confidential or
attorney-client privileged and may constitute inside information or trade
secrets. The contents of this email are intended only for the recipient(s)
listed above. If you are not the intended recipient, you are directed not
to read, disclose, distribute or otherwise use this transmission. If you
have received this email in error, please notify the sender immediately and
delete the transmission. Delivery of this message is not intended to waive
any applicable privileges.
Alright I think this is finally ready to be made a thing of the past! #5233 fixed the lingering bug in the cleanup code and will come out in vagrant 1.7.3
Yay! Thanks bud! ๐
Interesting that today is the first time I tried dhcp, immediately ran into this, and 15 minutes prior it was fixed. Thanks!! ๐
Just got bitten by this. Thanks for the workaround (since Vagrant 1.7.3 is not out yet) and the fix in 1.7.3 when it is out.
VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
worked for me.
+1
VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
worked for me too.
worked like a charm!
Also got this error with Vagrant 1.7.2.
VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
worked like a champ.
+1
Just encountered this error with:
Vagrant@1.7.2
VirtualBox@4.3.26r98988
VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
fixed the issue.
+1
VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
๐ ๐ ๐
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.
+1
+1
+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.
Vagrant noob here, definitely still an issue. VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
worked for me on OSx Yosemite
+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
+1 fresh vagrant fresh VB
+1
Thanks for this solution VBoxManage dhcpserver remove
fresh install of Vagrant 1.7.4 and VirtualBox 5.0.4 on Ubuntu 14.04.
Same error, fresh install of Vagrant 1.7.4 and VirtualBox 4.3
+1 for vbox 5.0.10 and vagrant 1.7.4 on Ubuntu 14.04
+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.
+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.
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.
Just got this error on Vagrant 1.9.1 vbox 5.1.22
This issue still appears to be very much broken unfortunately.
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).
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).
Just upgraded VirtualBox and Vagrant and had the very same problem.
Same here.
Freaking 5 year old issue still persist, smh.
My work is suffering from this. I need to be able to use virtual box.
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.