Sometimes I desire to have a VM on my local machine, which is running Max OS X 10.10. I prefer to be able to use SCP to transfer files from my host to my guest, usually some flavor of Linux.
It seems pretty straight-forward to set up a host only connection. There are articles all over describing exactly how it can be done. Here’s one and here’s another.
Under normal conditions, this works flawlessly. However, at work, we use Cisco AnyConnect (here is some marketing material if you’re interested), which hijacks my routing table and sends everything to the watchful eye of our network admins…or at least through their gateways and hops how they see fit. This means that even a local “host-only” route is over-written by whatever they have dictated. Here is my “host-only” route being sent out my VPN tunnel:
192.168.56 link#10 UCS 0 0 utun0
This means that if you want to have a local VM with which to play and experiment, connecting to it isn’t all that straight-forward. First, you have to disconnect from your VPN (AnyConnect > Disconnect). You’ll see that your VirtualBox local host-only route is gone completely:
$ netstat -nr Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 10.65.10.1 UGSc 53 315 en3 10.65.10/23 link#5 UCS 3 0 en3 10.65.10.1 4c:4e:35:77:77:41 UHLWIir 54 0 en3 600 10.65.10.97 127.0.0.1 UHS 0 0 lo0 10.65.10.99 68:5b:35:77:77:85 UHLWI 0 0 en3 644 10.65.11.255 ff:ff:ff:ff:ff:ff UHLWbI 0 3 en3 127 127.0.0.1 UCS 0 0 lo0 127.0.0.1 127.0.0.1 UH 71 839273 lo0 169.254 link#5 UCS 0 0 en3
The VirtualBox host-only interface may have an IP address, both on the host and the guest, but its route is not re-added to my routing table when I disconnect from the VPN. I have to go into VirtualBox > Preferences > Network > Host-only Network, remove the host-only interface (vboxnet0) and re-add it. Once I do this, its route is added to my routing table and I can connect to my VM guest!
$ netstat -nr Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 10.65.10.1 UGSc 65 315 en3 10.65.10/23 link#5 UCS 3 0 en3 10.65.10.1 4c:4e:35:77:77:41 UHLWIir 66 0 en3 527 10.65.10.97 127.0.0.1 UHS 0 0 lo0 10.65.10.99 68:5b:35:77:77:85 UHLWI 0 0 en3 571 10.65.11.255 ff:ff:ff:ff:ff:ff UHLWbI 0 6 en3 127 127.0.0.1 UCS 0 0 lo0 127.0.0.1 127.0.0.1 UH 73 840630 lo0 169.254 link#5 UCS 0 0 en3 192.168.56 link#11 UC 2 0 vboxnet 192.168.56.255 ff:ff:ff:ff:ff:ff UHLWbI 0 1 vboxnet