Vagrant: how to configure multiple NICs within a Vagrantfile?

networking, vagrant

Solution

Using Vagrant 1.6.1 and private networking with Virtualbox you can create multiple private ips just by repeating the config.vm.network definition:

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "precise64"

  config.vm.network "private_network", ip: "192.168.50.4"
  config.vm.network "private_network", ip: "192.168.50.5"
  config.vm.network "private_network", ip: "192.168.50.6"
  config.vm.network "private_network", ip: "192.168.50.7"

end

Problem

The official doc gives example only for 1 IP: http://docs.vagrantup.com/v2/networking/private_network.html ``` Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "192.168.50.4" end ``` Googling around I could find only 1 example of Multiple IPs: https://groups.google.com/forum/#!topic/vagrant-up/hqtdOEjjlsw ``` Vagrant::Config.run do |config| config.vm.define :web001 do |config| config.vm.box = "base" config.vm.forward_port("http", 5000, 8881) config.vm.forward_port("ssh", 22, 2222) config.vm.host_name = "web001.example.com" config.vm.network("33.33.33.10") config.vm.network("33.33.33.20", {:adapter=>2}) end end ``` but it doesn't work for me... Any help would be greatly appreciated....

Original source