Vagrant up failing for VirtualBox provider with E_ACCESSDENIED on host-only network
Asked Answered
M

4

20

After VirtualBox update vagrant up failing with the following error on Ubuntu:

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

Command: ["hostonlyif", "ipconfig", "vboxnet2", "--ip", "10.160.0.1", "--netmask", "255.255.255.0"]

Stderr: VBoxManage: error: Code E_ACCESSDENIED (0x80070005) - Access denied (extended info not available)
VBoxManage: error: Context: "EnableStaticIPConfig(Bstr(pszIp).raw(), Bstr(pszNetmask).raw())" at line 242 of file VBoxManageHostonly.cpp

Used versions:

  • Vagrant 2.2.14
  • virtualbox-6.1 6.1.28-147628~Ubuntu~eoan
  • Ubuntu 20.04.3 LTS
Monochromatic answered 26/10, 2021 at 11:27 Comment(1)
Same thing happens on macOS tooMalacology
B
38

As of VirtualBox 6.1.28, host-only network adapters are restricted to IPs in the range 192.168.56.0/21 by default (192.168.56.1 -> 192.168.63.254).

You can tell VirtualBox to allow additional IP ranges by configuring /etc/vbox/networks.conf. For example, to allow anything in the 10.x.x.x range you could use:

* 10.0.0.0/8

For more info, see the docs at https://www.virtualbox.org/manual/ch06.html#network_hostonly

Bridgettbridgette answered 29/10, 2021 at 11:38 Comment(5)
Awesome first answer Chris! Well done. For anyone who doesn't calculate masks in their head, the range 192.168.56.0/21 maps to 192.168.56.1 - 192.168.63.254.Lieb
Thank you so much. I would very much like to know the rationale behind introducing this in a patch version. It broke every single one of our vagrant boxes.Subterrane
Thanks @PaulParker. I've incorporated the expanded subnet range in the answer now.Bridgettbridgette
@Subterrane Unfortunately there aren't any clues in the commits. The relevant commits reference bug #10077, but that must be in some private Oracle bug tracking system as bug #10077 in the public bug tracker is 10 years old and unrelated to these changes.Bridgettbridgette
@Bridgettbridgette Sorry to ask almost two years later, but do you have any link(s) to the relevant commits?Impartial
H
7

After scanning through the VirtualBox documentation on host-only networks, you will see that for Solaris, Linux and MacOS the allowed ip range for host-only networks has changed. VirtualBox will now only accept IP addresses to be assigned in the 192.168.56.0/21 range. The errors above show that Docker is trying to create and assign a 192.168.99.1/24 address and mask.

There are now 2 obvious solutions, one would be changing the way how docker creates your machine so it fits in the “new” address space that VirtualBox now uses:

docker-machine create --driver virtualbox --virtualbox-memory "2048" --virtualbox-hostonly-cidr 192.168.56.1/21 default

We can also solve this at the other side of the problem, that is changing the behaviour of VirtualBox. In order to do this we need to create the file networks.conf in /etc/vbox:

sudo mkdir /etc/vbox
sudo nano /etc/vbox/networks.conf

In the networks.conf we can tell VirtualBox what networks we are allowing:

* 10.0.0.0/8 192.168.0.0/16

* 2001::/64

Hopfinger answered 24/2, 2022 at 18:42 Comment(0)
M
4

I managed to get past the error by downgrading to VirtualBox 6.1.26:

# check the available versions
apt-cache showpkg virtualbox

# stop VirtualBox machines

# downgrade VirtualBox version
sudo apt-get install virtualbox=6.1.26-dfsg-3~ubuntu1.20.04.2

The last command from above doesn't delete virtual machines data.

Monochromatic answered 26/10, 2021 at 11:27 Comment(1)
Can confirm this issue and solution with the same VirtualBox versions (both old and new versions) and Ubuntu 20.04.2. I was not using Vagrant, but was trying to change the host-only adapter through the GUI and through VBoxManage.Burgess
S
0

I needed my Vagrantfile to work out of the box on multiple machines (Ubuntu and Mac), so modifying /etc/vbox/networks.conf didn't work for me.

Instead I changed all my Vagranfile IP addresses to 192.168.56.0/21, as described by Paul Parker and an answer on a duplicate question.

I initially tried 192.68.56.0/21 first, per ChrisR's answer and the VirtualBox docs, which worked on Linux. But VirtualBox on Mac would only accept the other range (with 168 instead of 68).

Sacrarium answered 20/11, 2021 at 23:29 Comment(1)
This should actually have been 192.168.56.0/21 all along. I thought at the time that it looked a bit odd and was probably a typo of the standard class B private network range. I've since checked the source and confirmed that this is the case (and the docs have since been updated too).Bridgettbridgette

© 2022 - 2024 — McMap. All rights reserved.