如何在VMWare Player 14.1.2(Ubuntu 18.04来宾,Windows 10主机)上进行端口转发? [英] How to do port forwarding on VMWare Player 14.1.2 (Ubuntu 18.04 guest, Windows 10 host)?
问题描述
我有一个在Windows 10主机上运行Ubuntu 18.04来宾的VMWare Player(14.1.2 build-8497320). Ubuntu来宾具有运行一些Web应用程序的LAMP堆栈.我正在使用NAT将Ubuntu来宾系统连接到Windows主机的网络.
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.
我可以使用访客的本地IP地址访问这些应用程序(例如, http://192.168.80.128/Windows主机上的mediawiki ).但是我想从Windows主机访问它,就像这样: http://localhost/mediawiki .我认为,如果我可以将Ubuntu来宾客户机的端口80转发到Windows主机的端口,则应该可行.
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.
请问我该如何做到这一点?我无权访问VMWare工作站及其虚拟网络编辑器.
How do I make this happen please? I don't have access to VMWare Workstation and its Virtual Network Editor.
我可能应该添加想要执行此操作的动机.基本上,我想避免每次访问Web应用程序时都要弄清虚拟机的IP地址.
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.
(进一步的)原因是(我怀疑)Ubuntu来宾的本地IP地址可能会更改,这会影响很多事情,例如在webapp的配置文件中配置的基本URL(例如, MediaWiki的LocalSettings.php中的$ wgServer变量).
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).
推荐答案
VMWare Player原生支持通过NAT进行端口转发:
VMWare Player supports port forwarding over NAT natively:
在文件C:\ProgramData\VMware\vmnetnat.conf
中的[incomingtcp]
部分下,插入以下行:
In the file C:\ProgramData\VMware\vmnetnat.conf
put under section [incomingtcp]
a line like:
80 = 192.168.80.128:80
然后重新启动VMWare NAT服务:
Then restart the VMWare NAT Service :
net stop "VMWare NAT Service"
net start "VMWare NAT Service"
来源/来源: https: //hitchhikingtheweb.wordpress.com/2014/09/02/portforwarding-with-vmware-player-and-nat/
也: 查看全文