更新 VirtualBox 后无法通过 Vagrant 创建私有网络

更新 VirtualBox 后无法通过 Vagrant 创建私有网络

我已经将 VirtualBox 从 6.1.26-2 升级到 6.1.28-3(在 Manjaro 中),然后我无法使用 Vagrant 设置私有网络。这是我的 Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.hostname = "Name"
  config.vm.network :forwarded_port, guest: 22, host: 2336, id: 'ssh'
  config.vm.network :private_network, ip: "10.1.45.3", netmask: "255.255.0.0"
end

当我执行 时vagrant up,我收到:为仅主机网络配置的 IP 地址不在允许范围内。请更新以前的地址以使其在允许范围内,然后再次运行该命令。

  Address: 10.1.45.3
  Ranges: 192.168.56.0/21

Valid ranges can be modified in the /etc/vbox/networks.conf file. For
more information including valid format see:

  https://www.virtualbox.org/manual/ch06.html#network_hostonly

我按照链接中的指南操作,并使用以下命令创建了文件 /etc/vbox/networks.conf:

0.0.0.0/0 ::/0

当我vagrant up再次运行时,我得到了:

The IP address configured for the host-only network is not within the
allowed ranges. Please update the address used to be within the allowed
ranges and run the command again.

  Address: 10.1.45.3
  Ranges: 

Valid ranges can be modified in the /etc/vbox/networks.conf file. For
more information including valid format see:

  https://www.virtualbox.org/manual/ch06.html#network_hostonly

为什么“范围”是空的?我尝试使用其他范围值,但没有任何变化。

我检查了 NAT 接口的 IP,没有冲突(10.0.2.15/24)。

答案1

*行首缺少一个。文件网络配置文件应该:

      * 0.0.0.0/0 ::/0

答案2

您可以使用 CIDR 表示法添加网络掩码和地址范围IP 地址范围说明为您想要从客户机向主机公开的 IP 地址。将以下内容添加到文件中/etc/vbox/networks.conf,然后执行以下操作vagrant reload

* 10.1.45.0/24

这有效地将 IP 地址的前 24 位(即前 3 个八位字节)分开用于网络,其余部分则是从 0 到 255 的地址范围。

相关内容