Select Page

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

At this point you will want to un-comment the last line with appropriate port (8080 in our case) to forward to the IP address of your Virtual Machine, or simply just add a new line in the format so desired. Thus for my example here, I add the following to the file:

8080 = 192.168.210.121:80

 

Step 3: After you have modified the NAT configuration file, you can either:

a. Stop / Restart your Virtual Machine.

-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.