Recently, I needed to make some network services in one of my VMware Fusion guest virtual machines available to other machines in my physical network. This guest VM is running Squid and is connected to my company's network through a VPN connection. A browser on the host OS X machine has no problem getting through over Squid on the guest machine, but I needed to have a native Windows machine in the physical network to get connected as well. It so happens that the guest VM networking is running in NAT mode, and so, by design, it is not directly accessible from the external, physical network.
The solution for establishing connectivity is actually very simple, using a not so well advertised feature of VMware Fusion.
VMware Fusion supports NAT port-forwarding, which in short, lets the host machine to forward traffic directed to a set of configured ports in a guest VM. To set this up, I needed to do the following:
- Edit the NAT configuration file to add the list of ports to be forwarded in this mode. To support HTTP proxy requests, I added port 3128 forwarding to the incomingtcp section of this file.
$ sudo vi "/Library/Application Support/VMware Fusion/vmnet8/nat.conf" ... [incomingtcp] 3128 = 192.168.19.69:3128 ...
- Restart VMware Fusion networking.
$ sudo "/Library/Application Support/VMware Fusion/boot.sh" --restart
No restart of VMware Fusion application or the guest VM is necessary. This configuration change takes effect immediately, and from this point on the host machine acts as a stand in for the guest and will forward all HTTP proxy requests to the guest VM.