Posts
58
Comments
405
Trackbacks
0
Connect to VMWare virtual machines using Remote Desktop

Had a short training on VMWare on Tuesday, the software development department finally got the official permission (read: get a license) to use VMWare Workstation.  I’m no stranger to Virtual Machines (VMs) – started playing with Virtual PC 2005 a fwe years back and I understood the general concepts of hardware virtualization.  The biggest problem I have with VMs in general is the slowness; I’d rather develop directly on my PC, which is faster.  Can’t say I’ve delved deep into it, but I know enough to utilize it and be dangerous .

Regardless, virtual machines provide a way to simulate multiple computers and I’ve done 3-tier software testing (client to app server using WCF and app server to SQL 2005 backend) to verify our framework can support both 2-tier (client –> DB) and 3-tier deployments.  Rarely used it for development, again due to speed.

Fast forward to the current time, I’d like to be able to do some coding on Windows 7; unfortunately Windows 7 is not quite sanctioned yet to be deployed, and it’s a pain to have to dual-boot.  I do have Windows 7 at home, but got way too many experimental stuff on it .  So, I’m setting up a Windows 7 VM so I can do some coding on it.

Now, nothing wrong with running the VM within VMWare, but I always find that it is a bit sluggish unless I go to full screen mode.  If I do so, it’s a bit of a pain to go back and forth between the host and the VM, and it also means that I have to do it at the host.  Ideally, I’d like to remote desktop into it (for whatever reason, I also feel remoting into a VM session makes for a snappier UI response).

However, this is not immediately possible to do without some setup; out of the box VMWare provides VNC connectivity, so you can use that but I am spoiled by remote desktop – it is just way nicer than VNC.  Of course one of the advantages of VNC is that if someone connects to it, the original don’t lose the view of the PC, so different tools for a different job.

In any case, I’d like to be able to remote desktop into my VMs – there are 2 ways to set this up, one is faster but it is considered as ‘nice’ and may cause problems with typical corporate network setups.  Let’s look at the first approach:

image

The first approach is to set up the VM setting to have it’s network adapter be a Bridged connection.  This basically sets the VM to use the host’s network card as if it were its own network card.  This also means that the VM will get an IP based on the host network’s settings (usually DHCP-based).  Essentially it brings the network connectivity of the VM to be at the same level as the host.  Now, in a corporate environment (usually domain-based), this may not be allowed, or you may have trouble with accessing the network at all if your VM is not added to the domain.  On a local (home) network, it also means it can communicate with other computers on the same network (good), but if it gets infected with a worm / virus it can also spread to the other computers (bad).

Depending on your environment, bridging may be fine and if you can do that then by setting it to Bridged mode you can then remote desktop to the VM (you have to remember to turn it on within the VM).

However, in my current situation, setting a VM network in bridged mode is not condoned and we have to set it to NAT setup.  Each VM that you spun will then get a typical internal IP address (192.168.XXX.XXX); but that means you cannot get to it from the outside.  So what to do?  The answer was provided in this post by rsa911– I’m just providing the nice UI snapshots (and also as a reminder for me on how I got it to work in the future).

In NAT mode, each VM is given an internal IP address and VMWare essentially becomes the bridge between the host and the VMs that runs in it.  Fortunately, you can do port forwarding to these internal IP address.  As detailed here, Remote Desktop uses port 3389 to listen to incoming RDP requests.  So what we need to do is forward an unused port to each VM’s port 3389 and we should be able to remote into them.  Let’s see how that’s done.

image

To do port forwarding, we need to access the Virtual Network Editor from VMWare Workstation (under the Edit Menu –> Virtual Network Editor).  The dialog above should show up – select the network adapter that is set to NAT.  Then click on the ‘NAT Settings…’ button, the following dialog will show up:

image

Click on the ‘Add’ button, and a dialog to map incoming port shows up; the dialog below is filled with the following information:

  • Listen to port 9997
  • Any TCP communication to that port, forward it to the VM with IP of 192.168.118.130 on port 3389 (default RDP port)

image

Tweak it to satisfy your setup – the host port just needs to be an unused port (in this example I use 9997), the VM port needs to be 3389 (unless you’ve changed it) and the VM IP address needs to be the IP address assigned to the VM you’re running (in Command Prompt run ipconfig to easily see this); this is what my output looks like:

image

When done, click OK and the NAT Settings dialog will show up your port forward:

image

So now I’ve set up VMWare so any incoming request to port 9997 will be forwarded to port 3389 on the VM that has IP of 192.168.118.130.  Remember that for Remote Desktop to work, you still need to make sure your VM has RDP enabled and you have users with passwords added as Remote Users.

The question is then how do you issue the remote desktop request?  Well, you use the host’s IP (or machine name) as the target, but you provide the port number as well:

image

The VMWare is hosted in my laptop (mbudimane6500) and I’m providing the port RDP should use (9997).  Remember that in a domain environment it’ll try to login as a domain user (DOMAIN_NAME\username format), so if your VM machine is not part of a domain you have to change the username to use to log in.

If you’ve done everything as mentioned above, now you can remote desktop into your VM machines in a NAT environment .  Remember also that you have to do the port forward for every VM that you wanted to remote into – each one will have a different IP address and each one will need to have a different port number.  Hope this helps others.

posted on Friday, November 13, 2009 8:42 AM Print
Comments
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
JerryO
11/25/2009 5:30 PM
Thanks Man, very helpful.
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
dotslasher
12/3/2009 10:47 AM
Nice post mate. I was using the bridged mode first. But your second option is much safer.

Thanks alot
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
K
3/2/2010 3:50 AM
Hi,
Thanks for the nice article,I am almost there.

Does this apply vmware server as well?

I have vmware server installed on my home PC(A) and running a VM Machine(B) on it. I am trying to RDP into that VM(B) from my work place computer(C).
Do I need to assign a static ip address to the guest(B) and also do i need to portforwarding on the router at home as well.

Thanks
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Praveen J
3/2/2010 10:01 AM
Nice tip, came in handy at the right time. Thanks.
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Muljadi Budiman
3/2/2010 12:36 PM
To K (please provide email next time):
I don't have experience with VMWare Server, but I would imagine the process will be very similar (if not exactly the same).

To answer your question, it really depends on the set up you have. If your VM machines are set up to use bridged connection, then you only need to port forward on the router at home to the RDP port set up on the guest (B) machine.

If you use NAT, then the guest machines IP won't be visible from the router, thus you still have to provide the translation from the host machine to the guest machine (you also still need to port forward on the router to your host (A) machine).
Gravatar
# Awesome article!
Dan
5/12/2010 9:25 AM
Wow, what a great article! Thank you so much this was exactly what i was looking for!!!!
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
asking
6/4/2010 6:35 AM
is this working if im tryng to acess through internet?
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
KC Abramson
6/11/2010 10:43 AM
This was a fantastic article. EXACTLY what i was looking to do. RDP and then VM Workstation just wasnt cutting it for me. I thank you sir
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
kfakfa
6/17/2010 1:05 AM
Ugly Thanx 2 days headache solved ! See u
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Philip
6/30/2010 4:51 AM
There is another easy way of doing this too. I use my router to assign a static IP address to my host using the host MAC address. This is so much easier.
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
anse
8/5/2010 5:38 PM
... and don't forget to activate this port in windows firewall :D ...


btw for those who use vmwareplayer: vmnetcfg is included in the install-file but won't be installed. Fortunately you can extract the exe by using /e switch; for detailed information search google or look here http://communities.vmware.com/message/1397634
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Moshe
8/8/2010 4:55 PM
Thanks for your EXCELLENT pictorial guide. Made something that could've been quite painful very simple.
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Brian
8/16/2010 3:20 AM
You can also use "localhost" as the hostname of the local machine. For example localhost:9991
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Raul
8/31/2010 8:30 AM
I need it for the KVM, someone to help me?
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
David
5/9/2011 9:45 PM
Excellent, just the info I needed!
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
kirill
9/12/2011 8:08 PM
thanks/ very usefull article
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Fred
9/15/2011 11:19 PM
Very interesting article ! Thanks
Gravatar
# Connect to VMWare virtual machines using Remote Desktop
Drow
11/2/2011 4:04 PM
I am running an internet cafe using thinclient boxes. These thinclients are pulling Windows XP professional via remote desktop from a host computer. I need to time control all the thinclients from this host computer (I'll call it PC-1). To achieve this, I need a second computer (I'll call it PC-2) that will house the server version of the cyberclock while PC-1 will house the client version of the cyberclock. Rather than purchase another PC, I opted to run your Vmware machine to act as PC-2. All the thinclients and PC-1 are lan connected on an ethernet swith to enable communication.
Now, I decided to swap roles by making PC-1 to become the Vmware VM housing the Guest OS, while PC-2 becomes the physical computer housing the Host OS. With this, the thinclients will have to pull their desktops remotely via RDP from the Vmware guest OS (PC-1) where the client-cyberclock will be installed; the server-cyberclock which resides on the Host machine (PC-2) will control the client-cyberclock.
I need a detailed guide on how to configure this setup to run as descibed above. Pictorial guide will really be appreciated. Many thanks.
-------------------------------------------------------------------------------------------
Brief setup Summary:

Thinclients ------->pull RDP session from windows XP pro installed on Vmware VM.

Sever-cyberclock installed on Host OS controls --------------> Client-cyberclock inside Vmware OS---------->controls all Thinclients.

Thanks in anticipation for your support.
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Jakim
11/18/2011 10:25 AM
Very well done. Thanks a LOT.
Go on doing it.
Regards,
Jakim
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Slappy
11/19/2011 6:40 PM
Cavalier BS, know it all attitude. Clearly focused on a few secondary considerations of using VMware Workstations. My suspicion is you have never actually used the product. Really sad that crap like thos shows up when searching for real world information
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
krishna
11/23/2011 7:22 PM
thanks for help
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Devarajan
12/4/2011 4:30 PM
very nice
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Worldunix
1/18/2012 4:36 PM
I wanted to thank you for the post. I do alot of SharePoint developement and need to be able to RDP to my Server on VMware :-)
Thx again

Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Jojo Man
3/5/2012 9:07 PM
Great Article bro :) keep up the good work
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Saravanan
3/13/2012 6:20 PM
Well explained. Thank you
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Navil
4/12/2012 10:09 AM
Thank you, your post was helpful. Do you know if vSphere Client installed on the host can connect to the vCenter server installed on VM?
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
N
7/13/2012 12:22 AM
Thanks for the article, i still הhave a problem.
I can connect to the VM (Win SRV 2008 R2)
via mstsc only from the host, where the VMWare player is running (my desktop)
but when i try to connect from other computer (my laptop)
in my home network it failed.
when i send ping from the laptop,
i can't even get ping from the host (my desktop) or the VM
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
jessa of memory improvement tips
8/6/2012 7:11 PM
Wow! does this really works? So much information in this site. Thanks a lot for the info.
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Nirmal
8/15/2012 2:21 AM
I did use the same thing mentioned in the article.But cannot connect to the VM linux machine from windows 7.Any Idea how to solve it?
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
sri
2/16/2013 7:35 AM
This is excellent article. Good work.
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
zues
3/10/2013 3:44 AM
Hi, I have set up a virtual machine, xp professional. My connection is wireless connection. I did all those steps you provided, I cant RDP into my machine. I pinged the machine to see if it is alive. It is not picking up on the network. Help please
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Danny
4/20/2013 7:03 PM
I didn't worked here until i openend port 9997 on the host (W7).
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Neonlights
5/22/2013 8:16 PM
I am on a domain environment, I have followed all the steps in the article. Just confused about what I need to key in on the RDC fields. When I try with my domain/username it doesnt connect. Any help would be appreciated, thank you in advance.
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
edrees yousif
5/27/2013 5:27 AM
show the code how to be connect and create remote vmware
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Satish
9/9/2013 10:42 PM
Nice post but it resolved my problem only 50%.

I have private network.
1. Router 192.168.0.100
2. Primary host machine 192.168.0.3
3. Host OS Win 7
4. VM connection - bridged.
5. Virtual machine - Win server 2008 - 192.168.0.128

What I want to achieve?
-------------------------
1. I want my vm to act as a server for my private network. Is it possible.
2. Can I access domain on server(VM) from machines connected to private network?

current problem ?
----------------------
1. I am able to ping my private network from virtual machine, but the private network cannot find virtual machines IP.
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
John Click
9/19/2013 7:21 PM
My primary concern for remote access has always been security (I work with sensitive information). So, for me, the safest solution I've found thus far is RHUB
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
N00b's N00b
9/24/2013 7:50 PM
VMware 10 by default remote desktop to my vmware based on its name I can connect to it but my vmware by default does not have a login/pass so how do I get in?
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
cabs
10/12/2013 7:53 PM
You could just install Teamviewer on the remote VM?
Gravatar
# re: Connect to VMWare virtual machines using Remote Desktop
Catherine
3/20/2014 4:06 AM
I knew this was possible! Thanks for the great tutorial, can't wait to go home and try it.

Post Comment

Title *
Name *
Email
Comment *