VirtualBox 提供程序 Vagrant 在仅主机网络上失败并出现 E_ACCESSDENIED

Zil*_*ili 20 ubuntu virtualbox vagrant

在 Ubuntu 上VirtualBox 更新vagrant up失败并出现以下错误后:

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
Run Code Online (Sandbox Code Playgroud)

使用的版本:

  • 流浪者2.2.14
  • virtualbox-6.1 6.1.28-147628~Ubuntu~eoan
  • Ubuntu 20.04.3 LTS

Chr*_*isR 38

从 VirtualBox 6.1.28 开始,仅主机网络适配器默认限制为 192.168.56.0/21 范围内的 IP(192.168.56.1 -> 192.168.63.254)。

您可以通过配置告诉 VirtualBox 允许其他 IP 范围/etc/vbox/networks.conf。例如,要允许 10.xxx 范围内的任何内容,您可以使用:

* 10.0.0.0/8
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅https://www.virtualbox.org/manual/ch06.html#network_hostonly上的文档

  • 太感谢了。我非常想知道在补丁版本中引入此功能的基本原理。它打破了我们每一个流浪盒子。 (4认同)

小智 7

浏览有关仅主机网络的 VirtualBox 文档后,您将看到对于 Solaris、Linux 和 MacOS,仅主机网络允许的 IP 范围已更改。VirtualBox 现在只接受 192.168.56.0/21 范围内分配的 IP 地址。上面的错误表明 Docker 正在尝试创建并分配 192.168.99.1/24 地址和掩码。

\n

现在有两种明显的解决方案,其中一种是改变 docker 创建机器的方式,使其适合 VirtualBox 现在使用的 \xe2\x80\x9cnew\xe2\x80\x9d 地址空间:

\n
docker-machine create --driver virtualbox --virtualbox-memory "2048" --virtualbox-hostonly-cidr 192.168.56.1/21 default\n
Run Code Online (Sandbox Code Playgroud)\n

我们还可以从问题的另一面解决这个问题,即改变 VirtualBox 的行为。为此,我们需要在/etc/vbox 中创建文件networks.conf:

\n
sudo mkdir /etc/vbox\nsudo nano /etc/vbox/networks.conf\n
Run Code Online (Sandbox Code Playgroud)\n

在networks.conf中,我们可以告诉VirtualBox我们允许哪些网络:

\n

* 10.0.0.0/8 192.168.0.0/16

\n

* 2001::/64

\n