KVM : Set VNC connection2025/01/17 |
Set VNC connection to connect to virtual machines with VNC. |
|
[1] | Edit existing virtual machine's configuration and start virtual machine with VNC like follows. The example on this site shows to create a virtual machine without graphics, so it's OK to change settings like follows, however, if you created virtual machine with graphics, Remove [<graphics>***] and [<video>***] sections in configuration file. |
# edit configuration of VM [root@dlp ~]# virsh edit centos10 <domain type='kvm'> <name>centos10</name> <uuid>09e64b69-19c7-4b47-a7cc-cd7b2f6708a0</uuid> <metadata> <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0"> <libosinfo:os id="http://redhat.com/rhel/10.0"/> </libosinfo:libosinfo> </metadata> ..... ..... # add like follows # set any password for [passwd=***] section for VNC connection # specify an unique number for [slot='0x**'] <graphics type='vnc' port='5900' autoport='no' listen='0.0.0.0' passwd='password'> <listen type='address' address='0.0.0.0'/> </graphics> <video> <model type='virtio' heads='1' primary='yes'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </video> <watchdog model='itco' action='reset'/> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/> </memballoon> <rng model='virtio'> <backend model='random'>/dev/urandom</backend> <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> </rng> </devices> </domain> Domain 'centos10' XML configuration not changed.[root@dlp ~]# virsh start centos10 Domain centos10 started |
[2] | If Firewalld is running, allow ports you use for VNC. |
[root@dlp ~]# firewall-cmd --add-port=5900-5999/tcp [root@dlp ~]# firewall-cmd --runtime-to-permanent |
[3] |
That's OK. Refer to the next section to connect to virtual machines from VNC client. |
[4] | By the way, if you'd like to enable VNC on initial creating of virtual machine, specify like follows. Then, it's possible to install Guest OS with VNC that requires GUI installation like Windows without installing Desktop Environment on KVM Host computer. |
[root@dlp ~]# virt-install \
--name Win2k25 \
--ram 8192 \
--disk path=/var/kvm/images/Win2k25.img,size=80 \
--vcpus=4 \
--os-variant=win2k22 \
--network bridge=br0 \
--graphics vnc,listen=0.0.0.0,password=password \
--video vga \
--cdrom /home/Win2025_26100.1742.240906-0331.ge_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso \
--boot uefi
|
Sponsored Link |
|