How to add a 'Host-only Adapter' to a VirtualBox machine via Vagrant file configuration?
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
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.