Chloe
Chloe

Reputation: 26264

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

I have this in my Vagrantfile

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

It's giving me this error when I try 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.

It uses a lot of words, but I still don't understand it. All of my virtual machines are powered off. Why can't there be more than one DHCP client on the network anyways? There are often multiple DHCP clients on the same network! All of my machines are using NAT adapters except for one using Bridged Adapter.

VirtualBox 5.2.4
Vagrant 2.0.1

Upvotes: 8

Views: 12597

Answers (4)

Edward Casanova
Edward Casanova

Reputation: 954

Instead of this:

 config.vm.network "private_network", type: "dhcp", netmask: "255.255.0.0", name: "vboxnet3", dhcp_ip:"10.101.0.2", dhcp_lower: "10.101.4.3", :dhcp_upper=>"10.101.4.254"

Add this:

 config.vm.network "private_network", type: "dhcp", netmask: "255.255.0.0", dhcp_ip:"10.101.0.2", dhcp_lower: "10.101.4.3", :dhcp_upper=>"10.101.4.254"

For the netmask, dhcp_ip, etc fields. Go to VirtualBox > Tools and look for your Host-only Networks.

enter image description here

Click on the DCHP Server tag. There you will find the fields to map:

  • Server Address -> dhcp_ip
  • Server Mask -> netmask
  • lower and upper are pretty evident

Upvotes: 1

onlyme
onlyme

Reputation: 4032

This issue may happens for different reasons. In my case when vagrant boots the vm, it brings up a other network adapter vboxnet2 while I have already created and attached an adapter vboxnet1. Thus, those two adapters were overlapping. This thread enter link description here helped me to solve my issue

Upvotes: 1

JPaulino
JPaulino

Reputation: 3477

I had the same error, and in my case I did the following: 1) Enabled a new 'host-only' adapter in virtualbox: just select your box, click 'settings', click 'network' and enable a different adapter than your other boxes have.

2) Check the ip of that adapter you created by running 'ipconfig' in powershell or command line in Windows.

3) Finally, in your vagrant configuration file, specify an ip within the adapter's network: config.vm.network "private_network", ip: "place_ip_here".

If your adapter's ipv4 is '172.28.128.1', for example, and subnet mask '255.255.255.0', then your first three numbers in the IP remain the same '172.28.128.another_number_here'

Upvotes: 0

lee-pai-long
lee-pai-long

Reputation: 2282

In Vagrant a public network is like a private one(in a pure networking sense) with dhcp that is implicitly bridged to your host so it can be accessed from outside your machine, it is a bit ambiguous as the documentation state.

So you are trying to create two networks using DHCP on the same hypervisor for the same machine, this cannot work with Virtualbox as Virtualbox can only assign one IP to one machine over DHCP.

If you don't need "the outside world" to access your machine the public network is useless, just use a private network over DHCP.

Or try using a public network with a private one with a static IP.

Upvotes: 2

Related Questions