Sometimes its useful to have the host of a virtual machine to be able to communicate directly with the virtual machine’s network.
Step 0 : Create the QEMU Bridge Configuration
Next lets create the qemu bridged configuration:
sudo pacman -S qemu sudo nano /etc/qemu/bridge.conf sudo chmod 755 -R /etc/qemu
Put the following inside
allow virbr0
sudo chmod u+s /usr/lib/qemu/qemu-bridge-helper
Next lets allow normal users to execute the qemu-bridge-helper
Step 1 : Install the prerequisites
Lets install the required packages
sudo pacman -S gnome-boxes virt-manager dnsmasq iptables iptables-nft
Note that if you cannot find one of the above packages its a good idea to update your mirrors (see: https://wiki.archlinux.org/title/mirrors)
Step 2 : Setup Lib-Virt Daemon
Lets enable the lib-virt daemon to auto-start
systemctl enable --now libvirtd
Next lets setup the kvm group so that it can manage the libvirtd
nano /etc/polkit-1/rules.d/50-libvirt.rules
Put the following inside
/* Allow users in kvm group to manage the libvirt daemon without authentication */ polkit.addRule(function(action, subject) { if (action.id == "org.libvirt.unix.manage" && subject.isInGroup("kvm")) { return polkit.Result.YES; } });
Next lets create the libvirt group if it doesn’t exist already and add ourselves to it
groupadd libvirt sudo gpasswd -a $(whoami) libvirt
Step 3 : Configure Networking
Next lets check the virsh interface status
sudo virsh net-list --all
If default exists then start it and set it up to autostart using:
sudo virsh net-start default sudo virsh net-autostart default
If default doesn’t exist then do this first and then the previous:
sudo virsh net-define /usr/share/libvirt/networks/default.xml
Next start up virt-manager and connect to KVM/QEMU
Run ifconfig to see if things went well. If they do then you should have a virbr0 interface now:
Now if you boot up the VM on gnome-boxes you should hopefully see an IP address on the same SUBNET.
Comments