I end up creating a script to launch my virtual machine. Limitation is that you have to launch the VM when VPN is off because Pulse Secure blocks creation of routes required.
I made this script a docked command for convenience -
#!/bin/bash
# visudo as root, add your_username ALL = (ALL) NOPASSWD:ALL
# vboxmanage list vms
guestip="192.168.86.3"
guestmac="8:0:27:22:4c:27"
vmname="WIN_ENT_10_64B"
# if the VM is running, leave it alone in peace:
vboxmanage showvminfo $vmname |grep "running (since"
[ "$?" -eq "0" ] && exit
# hide terminal window:
osascript -e 'tell application "Finder" to set visible of process "Terminal" to false'
# shutdown vbox network:
while [ -n "`netstat -rnf inet |grep $guestip`" ]; do
sudo ifconfig vboxnet0 down
sleep 1
done
# start VM and wait:
vboxmanage startvm $vmname --type separate
while [ -z "`netstat -rnf inet |grep $guestip`" ]; do
sleep 1
done
# delete original route:
sudo route -n delete ${guestip%.*}.0
# create a network singularity in routing table:
sudo route -n add $guestip/32 -interface vboxnet0
# create the host on the network:
sudo arp -s $guestip $guestmac
osascript -e 'tell application "Terminal" to quit' &
The scripts assumes that you can use sudo without a password.
guestip
is manually configured in guest OS on the "host only interface" (normally #2). When you create a "host only network adapter" in VirtualBox, it has DHCP enabled by default. I disable DHCP and assign a static IP in the guest OS manually for consistency reasons (here - 192.168.86.3, netmask 255.255.255.0 or CIDR /24, DNS left blank).
guestmac
is MAC address of the network interface in the guest OS that has the IP 192.168.86.3. Do not confuse it with MAC address of the "host only network adapter" in VirtualBox configuration. The latter is configured with 192.168.86.1/24 in our case (MAC a:0:27:0:0:0 below).
After the script completes (terminal app disappears from the dock), expected output of netstat -rnf inet
shall comprise similar entries:
192.168.86.3 8:0:27:22:4c:27 UHLS 3 4884 vboxnet
192.168.86.3/32 a:0:27:0:0:0 ULSc 0 0 vboxnet
These entries will persist across VPN connects/disconnects and let you access your VM locally regardless of the VPN state.
Possibly related: How do I setup Ubuntu/Linux’s network manager to selectively route network traffic through the VPN?
– G-Man Says 'Reinstate Monica' – 2017-12-12T16:08:04.827Possibly related: How can I make the Windows VPN route selective traffic (by destination network)?
– G-Man Says 'Reinstate Monica' – 2017-12-12T16:08:07.300