I'm trying to get vagrant to provision a VM with two network interfaces:
- eth0: NAT(virtualbox) type interface that talks to DHCP
- eth1: host-only(virtualbox) interface with a static IP
On virtualbox everything works. I get eth0 as a NAT type inteface that connects to the internet via DHCP and eth1 as a static IP with which I can connect to from the virtualbox host (I just need to add a private subnet to the virtualbox settings). However when I package this VM and try to deploy it as a box from vagrant I am unable to get eth1 to be brought up automatically as the MAC address gets changed by Vagrant (which means the static network configuration won't apply to it)
By default on vagrant the first adapter is always set as a NAT-ed interfance. This means I don't need to actually add anything in the vagrantfile for eth0.
For eth1 I've added the following in the Vagrantfile:
config.vm.network :private_network,ip:"192.168.100.201",:mac => "080027df863a", :adapter => 2
The problem: when I boot the vm (vagrant up) a new MAC is assigned for eth1. As a result the static IP mapping that I already have in /etc/sysconfig/network-scripts/ifcfg-eth1 is invalid (as it points to the MAC that was assigned when I create the VM in virtualbox).
If I delete the VM from virtualbox, repackage it and deploy a VM via vagrant with the same configuration the interface will get added but again the MAC address is different (and no initialization script will exist in /etc/sysconfig/network-scripts/)
TLDR: I want to create a vagrant box that has eth0 as a NAT-ed interface (DHCP) and eth1 as a static host-only interface (static IP). What's the best way to get it done as automated as possible? I don't want to have to be doing anything after the VM gets provision from the box.
Thanks