0

I'm getting this error:

There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* An IP is required for a private network.

when I follow this documentation: http://docs.vagrantup.com/v2/networking/private_network.html and specify that I want DHCP to assign the IP address like so:

config.vm.network "private_network", type: "dhcp"

Anyone know how to get this working?

EDIT:

I have also just tried:

config.vm.network :private_network, type: :dhcp

which works and assigns an IP address of 10.0.2.15, but I don't understand this as my DHCP server assigns addresses in the 192.168.1.x range? Does this stuff actually ever work for anyone?

3
  • By "my DHCP server" you mean an external one or the VirtualBox host-only adapter? If you need an ip address from an external dhcp you have to use a public network instead of a private one. Commented Apr 7, 2014 at 10:15
  • Hi @Emyl, I meant the DHCP server on my router. If it's the case that I need a public network, can you tell me why the docs say I can set the type as dhcp for a private one? How does that work then? Commented Apr 7, 2014 at 12:36
  • Private network is mapped to VirtualBox host-only network, so if you choose it you get an ip address from the VBox's internal dhcp server. Indeed, that's the easiest way to create a private network, that's the reason why it's mentioned in the docs. Commented Apr 7, 2014 at 13:47

1 Answer 1

1

If you want your Vagrant box to pull from the same DHCP your host box does, use this line in your Vagrantfile:

config.vm.network :public_network, :auto_config => true

This corresponds to a VBox bridged network, which it sounds like you want.

edit: added the auto_config bit. It should ask you which adapter you want to use when it boots; you can also specify :bridge => "en1" (or whatever your adapter happens to be named; en1 is my Macbook's USB ethernet) on that line to hard-code a host adapter name.

Sign up to request clarification or add additional context in comments.

2 Comments

Cheers, but when I do this, it hangs for about 10 minutes and then doesn't configure the network card with an IP address.
I added some more information to my original; I ran into that once but I thought it was just my DHCP server being ornery, so I didn't include the extra info. See if that helps now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.