In my previous post, I indeed do VirtualBox networking the hard way. I also hinted that there was a simpler solution. I tried out the alternate solution, and was successful.
The solution is to use VirtualBox Paravirtualized Network (virtio) drivers. They appear to be applied in ascending order to the PCI bus, and are numbered that way:
vagrant@test01:~$ dmesg | grep eth [ 4.444193] virtio_net virtio0 enp0s3: renamed from eth0 [ 4.454983] virtio_net virtio1 enp0s8: renamed from eth1 [ 4.488878] virtio_net virtio2 enp0s9: renamed from eth2
vagrant@test01:~$ lspci 00:03.0 Ethernet controller: Red Hat, Inc Virtio network device 00:08.0 Ethernet controller: Red Hat, Inc Virtio network device 00:09.0 Ethernet controller: Red Hat, Inc Virtio network device
This is the Vagrantfile to ensure that additional network interfaces are applied with the appropriate type:
Vagrant.configure("2") do |config| config.vm.box = "stretch" config.vm.box_url = "file://boxes/stretch.box" config.vm.provider "virtualbox" do |v| #v.memory = VM_MEM_SIZE #v.cpus = VM_CPU_COUNT #v.customize ["modifyvm", :id, "--cpuexecutioncap", "#{VM_CPU_CAP}"] v.customize ["modifyvm", :id, "--nictype1", "virtio"] v.customize ["modifyvm", :id, "--nictype2", "virtio"] v.customize ["modifyvm", :id, "--nictype3", "virtio"] #v.customize ["storagectl", :id, "--name", "SATA Controller", "--hostiocache", "off"] end config.vm.define "test01" do |test01| test01.vm.hostname = "test01" test01.vm.network "private_network", virtualbox__intnet: "net1", ip: "192.168.35.23" test01.vm.network "private_network", virtualbox__intnet: "net2", ip: "192.168.45.34" end config.vm.define "test02" do |test02| test02.vm.hostname = "test02" test02.vm.network "private_network", virtualbox__intnet: "net1", ip: "192.168.35.24" test02.vm.network "private_network", virtualbox__intnet: "net2", ip: "192.168.45.33" end end
With an acknowledgement to github comments for #2389
Link to VirtualBox: Chapter 6 - Virtual Networking