How to configure a bridged network for a QEMU/KVM virtual machine so that it's on the same local network connected to via WiFi?

5,087

So far what has worked for me was:

  • using aqemu for using the virtual machine with access to the Internet through the VPN connection.
    In the network tab of the virtual machine I selected Enable network and Connection mode Use the user mode network stack. I haven't found a way to set up a bridge for access to the local network in aqemu. Unlike the aqemu version in the Debian repos, the latest version of aqemu doesn't work in Debian without other changes because one gets the error qemu-system-x86_64: Invalid parameter 'vlan' (probably due to a mismatching version of qemu). You can probably also set libvirt up for VPN-Internet access (changing the NIC settings before starting or making two virtual machines for the same vm disk) but I prefer using aqemu (maybe that's partly because the version in Debian's repos was very outdated).
  • using Virtual Machine Manager (libvirt) for using the virtual machine with access to the local network and the Internet without the VPN.
    In the virtual machine's settings under NIC:... set Network source to the interface that has the local ip set (ip a) and set Source mode to Bridge.

After using libvirt one has to run sudo chown username:username path-to-vm-disk-file to allow qemu to access the vm disk in aqemu. I don't know how it would be possible to have the VM both access to the Internet through the VPN and to the local network or why guides like the ones linked above don't mention this setting in Virtual Machine Manager (I was using aqemu previously).

Share:
5,087

Related videos on Youtube

mYnDstrEAm
Author by

mYnDstrEAm

I care about making FOSS, cybersecurity and useful/important knowledge accessible. I learn, collaborate and develop with open source.

Updated on September 18, 2022

Comments

  • mYnDstrEAm
    mYnDstrEAm almost 2 years

    I'd like to configure my QEMU/KVM virtual machine which I set up using aqemu to be on the same local network as the host computer which runs Debian/KDE.

    Do I have to configure a bridge on the host computer and if so how? Or is there a way to do this with the aqemu GUI or the qemu console command?

    I'm using a VPN, the nftables firewall and network manager and I don't have a network interface called eth0 as described here and in the link in the comment below.

    When I follow this guide at step "How to turn on bridge interface" of that guide doesn't work: when running ip a s br0 the bridge doesn't have inet set and after running sudo nmcli con up br0 the bridge is orange, not green and the bridge-slave is grey, not green. (I can only make it so that when I run nmcli connection show --active my Internet connection and my VPN connection are green and bridge-br0 is orange.) When I run nmcli con up bridge-slave-ifname, I get: Error: Connection activation failed: No suitable device found for this connection (device enp0... not available because profile is not compatible with device (mismatching interface name)).

    I also tried it with libvirt (Virtual Machine Manager) and this guide but then I only get the error "Wired Interface (eth0) IP configuration was unavailable" in the VM and the virbr0 bridge would not be on the LAN.

    or is it impossible to make the virtual machine be on the same local network when connected to via WiFi via this method? What would be another method for that then?

    • Jonathan Roberts
      Jonathan Roberts about 4 years
      Have you tried something like this: linux-kvm.org/page/Networking?
    • mYnDstrEAm
      mYnDstrEAm about 4 years
      If you're referring to section Public Bridge there: my /etc/network/interfaces file doesn't have eth0 or the name of the interface I'm using. Also I don't have brctl or "ip link". I already tried creating a bridge in KDE's network manager. I'm not sure how to proceed.