Multiple network adapters in Vagrant

As part of our new infrastructure change we were updating our development environments in Vagrant to match our live servers. One of these changes was adding multiple network adapters to the boxes, I couldn't find anything on the internet that covered this perfectly - especially for version 2 of the Vagrantfile API.

Just add the following to the Vagrantfile:


config.vm.network "private_network", ip: "192.168.10.10"

That's it!

From what I can work out, Vagrant will add the above IP address as a secondary adapter, you can add more adapters by just adding another line with a different IP address.

More information

It is possible to specify the adapter number by adding the following to the above line

adapter: 1

This effectively overwrites the configuration for adapter 1. I tried to do this so my VM would only have the IP address(es) that I defined, but encountered a few problems. Vagrant had problems connecting to the VM. I couldn't solve the problem, so just left it out.