I have a mac book running Mac OS High Sierra. It is host to three virtual machines running Ubuntu 16.04. All VMs have two adapters enabled; NAT and Host-Only. The mac is connected to another host via a switch. The VMs co-ordinate and provide a service which I would like to be available to the host at the other end of the switch connected to my laptop.
en8
192.168.57.0 192.168.57.200 192.168.57.100 /---|VM1| 192.168.56.3
|------------| /--------------\ |--------------| /
| Host1 |--| switch |--| Host2 |------|VM2| 192.168.56.4
|------------| \--------------/ |--------------| \
192.168.56.1 \---|VM3| 192.168.56.5
vboxnet0
The hosts are on subnet 192.168.57.0\24. The laptop is connected to the switch through interface en8 with an IP address of 192.168.57.100. The laptop and the switch can ping each other.
Mac OS is connected to the VMs through gateway 192.168.56.1 on interface vboxnet0. The VMs can ping eachother and their host. The host can communicate with each VM.
I want the VMs to be able to control the switch, and so I need to set up a routing rule to connect traffic from the swtich to the VMs and back. I want to use my mac like a router to do this.
I tried following Jeff Warren's example here: Virtualbox: Connecting Host-Only networks on separate hosts, but it isn't working in my case.
Specifically, i tried...
sudo route -n add -net 192.168.56.0/24 192.168.57.100
but this didn't work. I got a message saying File already exists.
Any ideas on how I can make it possible to configure my switch from the VMs are much appreciated. Thank you.
I have tried other approaches, like putting the VMs on the same logical subnet as the switches. When I did this however, I lost communication between the VMs and their host. I also have tried using bridged network instead of host only, but this hasn't worked either.