How to do port forwarding on VMWare Player 14.1.2 (Ubuntu 18.04 guest, Windows 10 host)?
Asked Answered
M

2

12

I have a VMWare Player (14.1.2 build-8497320) running a Ubuntu 18.04 guest on a Windows 10 host. The Ubuntu guest has a LAMP stack that runs a few web applications. I am using NAT to connect the Ubuntu guest to the Windows host's network.

I can access these applications by using the local IP address of the guest (e.g., http://192.168.80.128/mediawiki) from my Windows host. But I want to access it like so from my Windows host: http://localhost/mediawiki. I think this should be possible if I can forward the port 80 of my Ubuntu guest to that of the Windows host.

How do I make this happen please? I don't have access to VMWare Workstation and its Virtual Network Editor.

Edit: I should probably add the motivation for wanting to do this. Basically, I want to avoid figuring out the IP address of the virtual machine everytime I access the web applications.

The (further) reason is that the local IP address of the Ubuntu guest might (I suspect) change, and that will affect quite a few things, such as the base URLs configured in the webapps' configuration files (e.g., the $wgServer variable in LocalSettings.php of MediaWiki).

Motherhood answered 18/9, 2018 at 12:41 Comment(0)
H
17

VMWare Player supports port forwarding over NAT natively:

In the file C:\ProgramData\VMware\vmnetnat.conf put under section [incomingtcp] a line like:

80 = 192.168.80.128:80

Then restart the VMWare NAT Service :

net stop "VMWare NAT Service"
net start "VMWare NAT Service"


Source/credits: https://hitchhikingtheweb.wordpress.com/2014/09/02/portforwarding-with-vmware-player-and-nat/

Also: VMWare documentation of this

Housel answered 5/3, 2019 at 10:2 Comment(0)
W
1

You can do it using SSH Tunneling for example.
From windows you open a tunnel from the windows port 80 to the ubuntu port 80.
You can do it using Putty on Windows and having the ssh deamon running on ubuntu, which I guess you should already have.

There are many tutorials on how to do this. I'll add just one link, but you can always google it and find one that suites you.

Portforwarding with SSH (Putty)

For the possible changes in the guest’s ip:

If you can’t fix the ip in settings then perhaps you can edit the windows hosts file and add a host name for the current Ubuntu ip. Then build the urls using the host name. If the ip changes you change it in the hosts file.

Wintergreen answered 18/9, 2018 at 12:54 Comment(3)
Thanks for your reply! Please see my edit. Your solution still requires me to figure out the IP address of the guest OS (i.e., do an ifconfig from the guest OS). My problem will be solved if I can either hardcode this IP address, or use port forwarding via VMWare's own settings (which will handle the IP address change automatically).Motherhood
See additional Info i added to my answerWintergreen
Thanks. I ended up doing precisely that after my last comment, resigning myself to hoping that the IP doesn't change often. I am still on the lookout for a more permanent solution.Motherhood

© 2022 - 2024 — McMap. All rights reserved.