VMware Workstation Player and Port Forwarding

To configure a PortForwarding on Windows 10 to a VM hosted on VMware Player it is necessary to proceed as follows:

  • Configure a static IP address (not essential but recommended) use the DHCP reservation function present in the virtualization application
  • Configure port forwarding.

Configure DHCP Reservation

  • Retrieve the MAC Address assigned to the virtual machine to which you want a static IP
  • Modify (with Notepad running in Administrator mode) the vmnetdhcp.conf file present in C:\ProgramData\VMware by inserting the following lines:

Host <Name of virtual network> {

hardware ethernet <Mac Address in this format xx:xx:xx:xx:xx:xx;

fixed-address <ip address>*;

}

Example:

#Static IP WIN11 –> Comment to identify the VM

VMnet8 host {
Hardware Ethernet 00: 0C: 29: 41: E8: 0C;
fixed address 192.168.233.10;
}

Where in our case the VMnet8 is the one assigned by default to the “NAT” configuration of the VM network card

  • Restart the VMNETDHCP service
    net stop vmnetdhcp
    net start vmnetdhcp

Port Forwarding Configuration

  • Modify (with Notepad running in Administrator mode) the vmnetnat.conf file present in C:\ProgramData\VMware by inserting the following lines:
    <tcpPortSource> = <IPaddress VM>:<tcpPortDestination>

Example:
8889 = 192.168.233.10:3389

In this case, we follow an RDP session to the OS system hosting my VM using: 8889 I will access through RDS to my VM with IP 192.168.233.10

*To check the IP range to always use the vmnetdhcp.conf file and identify the correct network segment; In the case of my example the segment is 8 (VMnet8)

# Virtual ethernet segment 8

# Added at 11/10/21 23:49:40

subnet 192.168.233.0 netmask 255.255.255.0 {

range 192.168.233.128 192.168.233.254;            # default allows up to 125 VM’s

option broadcast-address 192.168.233.255;

option domain-name-servers 192.168.233.2;

option domain-name “localdomain”;

option netbios-name-servers 192.168.233.2;

option routers 192.168.233.2;

default-lease-time 1800;

max-lease-time 7200;

}

VMware Workstation Player and Port Forwarding

Create a Shortcut connect to VM

We have three option to create a shortcut on Windows 10 to connect a Virtual Machine running on ESXi:

  • Use VMware Workstation
  • Use VMware Player
  • Use VMRC Console

In all of that options, we need have installed the correspondent application. With Workstation and Player, we can open the session with remote VM on FULL-Screen mode.

First, we need to recover the MOID identification of VM, connect with SSH to ESXi where is running the VM and launch this command:

[root@viESXi0:~] vim-cmd vmsvc/getallvms

The output show the VM inventory  on the ESXi and the relative MOID

In this example is 35

So we are ready to connect:

VMware Workstation

“C:\Program Files (x86)\VMware\VMware Workstation\vmware.exe” -f -H 192.168.1.201 -M 35

VMware Player

“C:\Program Files (x86)\VMware\VMware Workstation\vmplayer.exe”  -X -H 192.168.1.201 -M 35

VMRC

“C:\Program Files (x86)\VMware\VMware Remote Console\vmrc.exe” vmrc://root@192.168.1.201/?moid=35

Where 192.168.1.201 is IP or FQDN of ESXi and MOID or M the identification of VM (found with this command on ESXi Host vim-cmd vmsvc/getallvms

Create a Shortcut connect to VM