20

A lot of answers out there are only applicable version 1 of Vagrant file configuration. e.g.

config.vm.network :hostonly, :adapter => 2

The new public network does not support this feature. e.g. this line here

config.vm.network "public_network", bridge: 'vboxnet0'

Will throw an error because vboxnet0 is not a network interface like en0. Here is a screen shot:

enter image description here

I have also tried

config.vm.provider "virtualbox" do |vb|
  vb.customize ["modifyvm", :id, "--hostonlyadapter2", "vboxnet0"] 

But it has no effect on the virtual machine.

How can I create a new interface like this?

enter image description here

I am using

  • Mac OS X 10.10.1
  • VirtualBox 4.3.20
  • Vagrant 1.6.5

migrated from serverfault.com Dec 1 '14 at 4:42

This question came from our site for system and network administrators.

23

I think I have found an answer.

config.vm.provider "virtualbox" do |vb|
    config.vm.network "private_network", :type => 'dhcp', :name => 'vboxnet0', :adapter => 2
end

This will create a host-only adapter as I wanted in my question

  • Good to see this solved! You should check off this as the answer when you have a moment since this will clearly help others faced with similar issues. – JakeGould Dec 1 '14 at 18:09
  • Further to this, if you happen to have a custom DHCP server already configured, you need to make sure the dhcp_ip, dhcp_lower and dhcp_upper match your custom DHCP server otherwise vagrant will throw an error. – morloch Nov 13 '15 at 3:16
2
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  config.vm.network "private_network", type: "dhcp"
end

Works for me, though I already had 'vboxnet0' configured by default, it created a new host-only network 'vboxnet1'.

I was not able to use vboxnet0 further it throws conflicting network error. Creating multiple vms with above config worked for me using vboxnet1 by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.