You followed the steps here to install windows 11 on your KVM environment.
Now, you want to access the virtual machine for your day-to-day use.
how do you go about and access the windows 11 guest virtual machine from your host operating system?
There are two ways you can connect to the guest windows machine.
- Using virt-viewer software.
- Virt-viewer on the host
- Virt-viewer on the LAN
- Using RDP connection.
- RDP from the host machine.
- RDP from LAN network.
I personally like the RDP option, however, let’s look at both of them now.
Using virt-viewer software.
When you use virt-viewer software you can use it either from the local host or from the remote.
Let’s look at both options.
Virt-viewer on the host.
To access the windows 11 KVM VM using Virt-viewer software
You can log in to the host machine and open the terminal.
In the terminal type virt-viewer and choose windows 11 from the list and click on connect.
If it is powered off, you first need to power it back on and try to connect. Otherwise it will not show in the available virtual machines list.
If the VM is powered off and you are unable to find the windows11 to connect, to power on the virtual machine.
- you may type virsh list –all in the terminal.
- Check the status of the windows11 machine. It most likely is in a shut-off state.
- You may power them on with the below command.
- virsh start windows-11
once powered on you can use virt-viewer command to get back into the VM.
You can learn more about more useful KVM commands here.
Virt-viewer on the LAN
We just looked at how you can access the virt-viewer from the host machine, let’s see the same thing from the other hosts in the LAN network.
The only requirement for this to work is to enable SSH with x11 forwarding.
If SSH is not enabled on your Ubuntu machine, you can enable it with the help of this article here.
Using x11 forwarding on the terminal, you can virtually open any application on the remote Linux host.
For example, if you would like to open firefox, you can ssh into the remote host and simply type firefox in it.
You can use the firefox browser virtually from the remote host.
Similarly, you can even use the virt-viewer from another machine in your local area network, but it should have x11 forwarding enabled.
As you can see, I ssh into my KVM host from another windows machine in my LAN using the mobaxterm client.
And I typed virt-viewer and got a prompt to choose the virtual machine.
I use mobaxterm, as it has x11 forwarding enabled by default.
If you use other console applications for eg: putty or securecrt, it should work fine as well, provided you should manually configure the x11 forwarding.
Otherwise you will get an error “Cannot open display”
Using RDP connection.
The second method is to connect to the windows 11 virtual machine in KVM is to use RDP connection.
The remote desktop is a popular way of connecting your windows 11 vm remotely.
By default when we installed windows 11 on KVM, we installed it using the default NAT network interface. Which means, the VM can go out to the internet, and the host machine can connect to it as well.
Because the host machine uses its IP to provide network services to the guest VM, other machines in your LAN cannot communicate with the virtual machine.
From the LAN perspective, it is the host machine that initiates the communication.
To prove that, I have just initiated ping from my windows 11 machine to google public DNS IP 184.108.40.206
And in my packet capture it shows the host machine has basically initiated the communication.
Which means you can only RDP into the machine from your local machine. Not from any other LAN network, because the IP address 192.168.122.195 has the reachability from the host machine not from your LAN.
To connect to the Windows virtual machine using RDP.
Enable RDP on the Windows 11 virtual machine.
Connect to the virtual machine either through virt-manager or virt-viewer.
Under system, click on Remote Desktop
Enable the Remote Desktop option.
You will get a prompt, click on confirm and you are ready to share the Remote desktop connection.
RDP from host machine.
In Linux you can use a software called Remmina, which is by default pre-installed in the ubuntu.
If not available, you may download from the software center or enter the command below to install it.
sudo apt-get update
sudo apt install remmina
Once you have the software on the linux machine.
Open it, in the drop down on the left, choose RDP and enter the IP address of the windows 11 virtual machine and hit enter.
Note: You can get the IP address of the machine by going to the command line as I mentioned before.
Enter the username and password and click on OK.
The Domain name is optional though.
As you can see, I have connected to the windows 11 VM successfully now, you might need to play around with the RDP resolution in the settings to get optimal resolution.
RDP from LAN network.
Like I mentioned, you cannot directly RDP into the system from your LAN network.
For that, you need to use a bridged network and bring a KVM virtual machine to your LAN network instead of the default virtual NAT network.
You can follow the step by step guide on how you can do that here.