这个 Vagrant 错误是什么意思,如何解决?对于 'public_network' 和 'private_network' 在一起

What does this Vagrant error mean and how do you fix it? For 'public_network' and 'private_network' together

我的 Vagrantfile 中有这个

Vagrant.configure("2") do |config|
  config.vm.network "public_network"
  config.vm.network "private_network", type: "dhcp"

当我尝试 vagrant up

时出现此错误

==> default: Clearing any previously set network interfaces...
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.

用了很多字,我还是没看懂。我所有的虚拟机都已关闭。为什么网络上不能有一个以上的 DHCP 客户端呢?同一个网络上经常有多个 DHCP 客户端!除了一台使用桥接适配器之外,我所有的机器都使用 NAT 适配器。

VirtualBox 5.2.4
流浪汉 2.0.1

在 Vagrant 中,public 网络就像一个带有 dhcp 的私有网络(在纯网络意义上),它隐式桥接到您的主机,因此可以从您的机器外部访问它,这有点模棱两可作为 documentation 状态。

所以你试图在同一台机器的同一个管理程序上使用 DHCP 创建两个网络,这不能与 Virtualbox 一起使用,因为 Virtualbox 只能通过 DHCP 为一台机器分配一个 IP。

如果您不需要 "the outside world" 访问您的机器,public 网络就没用了,只需使用基于 DHCP 的专用网络。

或者尝试将 public 网络与具有静态 IP 的私有网络结合使用。

我有同样的错误,在我的例子中,我做了以下事情: 1) 在 vi​​rtualbox 中启用一个新的 'host-only' 适配器:只是 select 你的盒子,点击 'settings',点击 'network' 并启用一个不同于你的其他盒子的适配器。

2) 在 powershell 或 Windows.

的命令行中检查您通过 运行 'ipconfig' 创建的适配器的 ip

3) 最后,在你的 vagrant 配置文件中,在适配器的网络中指定一个 ip: config.vm.network "private_network", ip: "place_ip_here".

例如,如果您的适配器的 ipv4 是“172.28.128.1”,子网掩码是“255.255.255.0”,那么您 IP 中的前三个数字将保持不变“172.28.128.another_number_here”

出现此问题的原因可能多种多样。在我的例子中,当 vagrant 启动虚拟机时,它会启动另一个网络适配器 vboxnet2,而我已经创建并附加了一个适配器 vboxnet1。因此,这两个适配器是重叠的。 这个帖子 enter link description here 帮助我解决了我的问题