This is one of these things I just needed to āwriteā down so that I could reference later. I have a MacBook Pro laptop running OS X, and Iāve also got VMware Fusion installed. Iāve got quite a few different VMās installed (Windows 10, Ubuntu, Fedora server, etc.)
I was doing some Apache web server work on my Fedora Server VM, and fired up Apache to listen on port 80 (default) on my VM. Everything is good on that front. The part that needed a bit of tweaking however was on the VMware Fusion side. You see I want to be able to open a browser running locally on my MacBook Pro (acting as the VMware āhostā in this setup) and navigate to http://localhost:8080 and have it hit forward to port 80 on my Fedora Server Virtual Machine (which is the VMware āclientā in this scenario) as opposed to my OS X system on my MacBook Pro trying to āacceptā and respond to the request.
In order to do this, all we really need to know is the IP address of the Virtual Machine, and then we are all set. This configuration will require us to configure VMwareās NAT port-forwarding. Without further delay…
Step 1: Open the NAT configuration file for VMware Fusion (Iām a āviā type of guy), hence:
sudo vi /Library/Preferences/VMware Fusion/vmnet8/nat.conf
Step 2: Find the section of the configuration file that begins with [incomingtcp]
– You will see a section that looks something like the following:
[incomingtcp]
Ā # Use these with care – anyone can enter into your VM through these…
Ā # The format and example are as follows:
Ā #<external port number> = <VM’s IP address>:<VM’s port number>
Ā #8080 = 172.16.3.128:80
8080 = 192.168.210.121:80
Step 3: After you have modified the NAT configuration file, you can either:
-OR- (and my preference)
b. Just run the appropriate vmnet-cli commands to stop/restart the Virtual Machine networking.
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli āstop
sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli āstart
What does this do exactly? It allows you to open your favorite browser on your Mac (Safari/Chrome/Firefox) and navigate to http://localhost:8080, at which point the request will be āport forwardedā to the IP address of your Virtual machine at port 80.