Using VirtualBox host networks with vagrant

I have a few VirtualBox VMs that I use to test clustering, Gluster, Ceph and various other technologies. These hosts have a NAT interface as well as a host network for internal communications. This week I revamped several of my Vagrantfiles to use a host network and learned a few things in the process. To get a machine to ‘vagrant up’ and connect to an existing VirtualBox host network I first had to install the vbguest plug-in:

$ vagrant plugin install vagrant-vbguest

Copy iso file /usr/share/virtualbox/VBoxGuestAdditions.iso into the
box /tmp/VBoxGuestAdditions.iso
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 5.1.6 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.6 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ... Building Guest Additions kernel modules.

Once this plugin was installed I added a “private_network” stanza similar to the following to each Vagrantfile: "private_network", ip: ""

Then I ran ‘vagrant up’ and my machines could see the host networks my VirtualBox VMs reside on. Niiiiice!

This article was posted by Matty on 2017-02-02 18:16:00 -0400 -0400