7

I am in my home network with two machines set up: A and B. Both are running Win 10 Pro and have been updated regularly (no outstanding updates as of my check today).

A is the host machine where the VM is set up and stored, B is the machine I am using to actually access the VM. Using Hyper-V Manager, it's possible for me without any issues to access the VM on A from B. Now, I want to go down the RDP route in connecting to my VM. As far as I understand, Hyper-V Manager is already using RDP to connect, it's just packaged a bit differently.

However if I try to use RDP... I am lost how to actually connect. What I have tried so far:

  • Use the PC name of my VM. RDP gives me an error telling me it can't find the machine
  • Use the IP as displayed in Hyper-V Manager in the Network section (and also the same as ipconfig returns on the VM itself). Here the result is that I am getting a can't connect error.

I did try using A to RDP to my VM via it's PC name and that works without issue. So how would I connnect to the VM from B?

2
  • I did try using A to RDP to my VM via it's PC name and that works <-- Your Hyper-V guests is likely a NAT connection (mine is). I think you may need to try a Bridged connection for a different machine to access the guest on machine A.
    – John
    Commented Jul 2, 2021 at 14:19
  • I solved your problem - Any luck?
    – John
    Commented Jul 5, 2021 at 1:53

5 Answers 5

8

I did try using A to RDP to my VM via it's PC name and that works without issue. So how would I connnect to the VM from B?

The Hyper-V Guest Machine in Machine A defaults to a NAT network, nominally 172.16.x.y. I verified this on my on Hyper-V Guest machine.

You need to change your Hyper-V Guest machine to "Bridged" Networking. Hyper-V calls it External. Same thing.

I am using a Kali Linux Guest machine. You need to set up for your Guest Machine.

Summary:

  1. Add an External Switch (Bridged Mode) to the Hyper-V Manager on Machine A.
  2. Change the network settings in the Guest to External and restart the Guest and make a note of the IP address.
  3. Add RDP Protocol (xrdp) to the Guest if necessary. Windows Guest does not need this - already there.
  4. Log out of the guest machine (but do not shut it down).
  5. From Machine B. open RDP, enter the IP of the Machine A guest, user name and connect.

It works.

1. Add an External Switch to Hyper-V

enter image description here

2. Change the Guest Settings to use the External Switch (Bridged Mode).

enter image description here

If your Guest Machine is Linux, be sure to set up xrdp

Set up xrdp on Linux

sudo apt install xrdp

sudo systemctl enable xrdp

3. On Machine B, connect by RDP. Be sure to log out of the Guest machine A. RDP will log out of a Windows Guest but does not know what to do with a Linux guest.

enter image description here

4. It all works. I am working on Machine B. Here is a screen shot of Kali on Machine A

enter image description here

I have carefully laid out all the steps so you can change Hyper-V as needed and so you can see that it all works assuming you use an External Switch (Bridged Mode). NAT will not allow you to connect.

5
  • That's a great suggesstion. Thanks for the detailed explanation. I see now that it has to be a bridged connection and I tried it out getting exactly the expected result! This in itself has led me to a different set of problems (internet connection is now spotty on both the host machine and the VM when using the bridged connection...) but that's a topic for a different question.
    – Haris
    Commented Jul 5, 2021 at 19:51
  • Yes. Hyper-V setup (NAT, Bridged, other settings) should not affect the host machine. I had no connection issues here on either machine or opening the Guest machine via RDP. Not here at any rate. I will watch for your other question.
    – John
    Commented Jul 5, 2021 at 20:43
  • Thanks. This worked for me. Commented Feb 6, 2022 at 20:59
  • @John thanks for the answer, do you know how to use a hostname rather than an ip address to connect? Commented Sep 28, 2023 at 18:50
  • You would need to enter the host name in a HOSTS file in the source machine. That is a common way to use Host Name instead of IP address when there is no DNS server.
    – John
    Commented Sep 28, 2023 at 18:54
4

All the answers here - beside pointing out network problems with NAT - states that within the guest OS, the RDP stack must be installed - but this is not neccessary.

Hyper-V allows to control a virtual machine via RDP WITHOUT installing RDP in the guest OS.

Create a new text file (name it: xyz.rdp) with the following content:

full address:s:Hyper-v server name or IP
pcb:s:Hyper-V VM ID
server port:i:2179
negotiate security layer:i:0
  • Replace "Hyper-v server name or IP" with the real IP (or localhost if you run your mstsc directly on the machine where the hypervisor is) of your Hyper-V host

  • Replace "Hyper-V VM ID" with the ID of your VM (to find out the ID of your VMs, open Powershell on your Hyper-V host and type:

    get-vm | select name, ID

(the ID is the GUID)


Then save the RDP file and doubleclick it.

It will ask for a user name and password. Type here the credentials of the administrator's account of the hyper-v host, accept the self-signed certificate et voilà: you are connected to your virtual machine directy.

Please note: that no copy and paste between host and guest will work - but you can control any type of guest OS (including Linux) with this without installing anything RDP within the guest.

** If you get an error message from remote desktop, make sure your user (if not the administrator account) is a member of Hyper-V Administrators group.

7
  • xRDP doesn't work on the latest version of Kali 2023.3 - the port 3389 never opens even when service is running and you add a firewall rule, so it looks like this is the only answer here that will work (with Hyper-V). I'm sure there's a tweak, but I haven't found it yet!
    – MC9000
    Commented Oct 31, 2023 at 4:00
  • 1
    Figured it out. Make the RDP user a member of Hyper-V administrator. It works perfectly! thanks
    – MC9000
    Commented Nov 1, 2023 at 11:39
  • Why the downvote? Above method works perfectly without installing anything within the virtual machine regarding RDP. This works directly with the hypervisor. Commented Nov 3, 2023 at 18:50
  • 1
    I meant to hit the up vote and clicked the wrong thing (i scrolled inadvertantly while clicking). StackExchange wouldn't let me change it until my comment was accepted or some nonsense like that. Sorry about that!
    – MC9000
    Commented Nov 9, 2023 at 11:20
  • where did you find that pcb line setting? i cant find any reference on the web
    – mikew
    Commented Dec 28, 2023 at 18:30
0

updating my findings here for benefit of others,

  1. you can connect remote desktop in an VM running on Windows 10 Pro only. refer to windows documents for OS supporting RDP access 2.you need to enable "remote desktop in VM machine by logging into that machine.(refer to windows documentation how to enable RDP, check the requirements that suits you, for e.g options like you can connect machine B through LAN or you can access machine B through network outside of your home network etc)
  2. ensure that you are connected to Hyper-V installed machine and machine B in same LAN network i.e same router.
2
0

VM ID” property to true. Enter the identification in the new property discipline that simply seemed in the connection area and set the port to 2179.

1
  • 1
    What??? This looks like a partial answer (which might be helpful if it were complete). Can you update your answer to give the full details?
    – leanne
    Commented Aug 23, 2023 at 21:04
0

I had Ubuntu 18.04 VM on Hyper-V to which I couldn't RDP.\

Following steps worked out in my case:

  1. Setting use_vsock=false in /etc/xrdp/xrdp.ini
    (For this you need to have xrdp installed).
  2. Restart xrdp service sudo systemctl restart xrdp
  3. Complete shut down of my VM and then starting it again.
  4. Once VM in running state initiate RDP connection.

Things that I tried that didn't actually work out in my case:

  1. Replacing network switch of my VM on Hyper-V from NAT to bridged.
  2. Check/Uncheck enhanced session setting on Hyper-V.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .