I was recently working with Vagrant and the Vagrant VMware Fusion Provider Plugin to add a secondary NIC on-the-fly. Vagrant provides functionality to easily add a secondary NIC but you are required to assign it to a network. I didn't want to assign it to any network, I just wanted the secondary NIC present.
The Vagrant VMware Fusion Provider Plugin has the ability to modify VMware Fusion virtual machines through the use of VMX customization, but according to the Vagrant docs:
VMX is an undocumented format and there is no official reference for the available keys and values.
So, where do you find all of the VMX parameters that you can use if they are undocumented? The answer is actually very simple.
Fire up VMware Fusion and create a VMware Fusion virtual machine (but do not start it). Customize the virtual machine however you like. Assuming you named the virtual machine vm1, navigate to the default location where the vm1 virtual machine is stored:
cd ~/Documents/Virtual\ Machines/vm1.vmwarevm or
cd ~/Documents/Virtual\ Machines.localized/vm1.vmwarevm. Now that you are in the container directory for the virtual machine you just created, open the vm1.vmx file. This file contains all of the VMX parameters that apply to the virtual machine; if there is a parameter in the VMX file you can customize it through Vagrant on-the-fly.
However, not every VMX parameter will be present in the VMX file. For example, as mentioned above, I wanted to add a secondary NIC, but in the vm1.vmx file there were only entries for ethernet0. Common sense tells me a secondary NIC will probably be ethernet1, so how do I get those entries into the VMX file?
Fire up VMware Fusion again, go to the Settings of the vm1 virtual machine, click Add Device..., select Network Adapter, click Add..., select Private to my Mac, and close the Settings window. Now there is a secondary NIC assigned to the virtual machine. Open the vm1.vmx file again and search for ethernet1. You should now have the following parameters:
ethernet1.present = "TRUE" ethernet1.connectionType = "hostonly" ethernet1.virtualDev = "e1000" ethernet1.wakeOnPcktRcv = "FALSE" ethernet1.addressType = "generated"
These parameters can be put into your Vagrantfile to add a secondary NIC on-the-fly. This is how the Vagrantfile would look:
# -*- mode: ruby -*- # vi: set ft=ruby : VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "precise64" config.vm.provider "vmware_fusion" do |v| v.vmx["ethernet1.present"] = "TRUE" v.vmx["ethernet1.connectionType"] = "hostonly" v.vmx["ethernet1.virtualDev"] = "e1000" v.vmx["ethernet1.wakeOnPcktRcv"] = "FALSE" v.vmx["ethernet1.addressType"] = "generated" end end
vagrant up --provider vmware_fusion you should be able to login via
vagrant ssh and run
ifconfig eth1 to see your secondary NIC present but not assigned to any network.