Set up KVM/QEMU on Fedora 39 for RHCSA Practice.
- First, verify that your CPU supports virtualization:
grep -E 'vmx|svm' /proc/cpuinfo
If you see output, your CPU supports virtualization.
- Check if KVM modules are loaded:
lsmod | grep kvm
You should see kvm_intel
(for Intel CPUs) or kvm_amd
(for AMD CPUs).
- Install the required packages:
sudo dnf groupinstall "Virtualization"
sudo dnf install bridge-utils libvirt virt-install virt-manager virt-viewer
- Start and enable the libvirtd service:
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
- Add your user to the libvirt group:
sudo usermod -aG libvirt $USER
sudo usermod -aG kvm $USER
You’ll need to log out and back in for these changes to take effect.
- Verify the installation:
virsh list --all
This should show an empty list of VMs without any errors.
- Set up the default network:
sudo virsh net-start default
sudo virsh net-autostart default
- Launch Virtual Machine Manager:
virt-manager
Basic network configurations will be automatically created, including:
- default NAT network (192.168.122.0/24)
- virbr0 bridge interface
Also, make sure to download a Rocky Linux or AlmaLinux ISO (these are free RHEL alternatives) if you want to start creating VMs for RHCSA practice.
next blog posts will be about :
- Creating your first VM using virt-manager
- Setting up additional networks for VM-to-VM communication
I notice both your VMs are using the same network (192.168.122.0/24) with br0 having the same IP (192.168.122.100) on both machines. Let’s set up distinct IP addresses and configure them properly.
Here’s how to configure different IP addresses for your VMs:
- First, let’s modify the network configuration in VM1. Create/edit the network script:
sudo nmcli connection modify br0 ipv4.addresses 192.168.10.10/24
sudo nmcli connection modify br0 ipv4.gateway 192.168.10.1
sudo nmcli connection modify br0 ipv4.method manual
sudo nmcli connection up br0
- For VM2, set a different IP address:
sudo nmcli connection modify br0 ipv4.addresses 192.168.10.20/24
sudo nmcli connection modify br0 ipv4.gateway 192.168.10.1
sudo nmcli connection modify br0 ipv4.method manual
sudo nmcli connection up br0
Alternatively, you can configure this using the traditional network configuration files:
For VM1 (/etc/sysconfig/network-scripts/ifcfg-br0):
TYPE=Bridge
BOOTPROTO=none
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.10.10
PREFIX=24
GATEWAY=192.168.10.1
For VM2 (/etc/sysconfig/network-scripts/ifcfg-br0):
TYPE=Bridge
BOOTPROTO=none
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.10.20
PREFIX=24
GATEWAY=192.168.10.1
After making these changes:
# Restart the network service
sudo systemctl restart NetworkManager
# Or bring the interface down and up
sudo nmcli connection down br0
sudo nmcli connection up br0
To verify connectivity:
# From VM1
ping 192.168.10.20
# From VM2
ping 192.168.10.10
If you want to create a completely separate network for practice:
- Create a new bridge network in libvirt:
cat << EOF > bridge-network.xml
<network>
<name>bridge10</name>
<bridge name='br10'/>
<forward mode='route'/>
<ip address='192.168.10.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.10.100' end='192.168.10.200'/>
</dhcp>
</ip>
</network>
EOF
sudo virsh net-define bridge-network.xml
sudo virsh net-start bridge10
sudo virsh net-autostart bridge10
- Then attach this new network to your VMs:
sudo virsh attach-interface --domain vm1 --type network --source bridge10 --model virtio --config --live
sudo virsh attach-interface --domain vm2 --type network --source bridge10 --model virtio --config --live