You are not logged in.

#1 2024-02-26 12:34:40

Markus.N2
Member
From: Germany
Registered: 2013-08-22
Posts: 99

Need help understanding Qemu/KVM/libvirt bridged networking

Hi all,
I'm trying to transition from VirtualBox to libvirt (with virt-manager on top) and I have some problems understanding the "bridged networking" topic. The final goal I need to achieve is that the guests (a.k.a. VMs) show up as individual DHCP clients on my router box. With VirtualBox, this is possible, so I know at least that there are no technical limitations that prevent this. However, I don't know if the qemu/libvirt stack supports this.

Correct me if I'm wrong, but as far as I understand, this means that any example configuration that involves host-internal DHCP won't do the job. I also think that I shouldn't need to configure iptables on the host.

I've did a lot of reading, but I found found the documents contradict each other a bit or are incomplete (i.e. miss some basics that the writer seems to assume as self-understood), some mention a "tap" device, some don't, ...

This is what I did so far:

virsh net-define /etc/libvirt/qemu/networks/default.xml
virsh net-edit default
virsh net-autostart default
virsh net-start default

And set the guest from User mode to Bridged networking.

The file /etc/libvirt/qemu/networks/default.xml came with installing bridge-utils.

Using the net-edit command, I've changed the forward mode from nat to route. But I'm unsure what to do with the dhcp section still being part of the configuration. Below is my configuration after net-edit. The mac address is the one of the bridge device, not the host's ethernet adapter.

<network>
  <name>default</name>
  <uuid>c47056d5-4403-4aca-ac05-728a513b8dca</uuid>
  <forward mode='route'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:e0:05:91'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
</network>

This configuration gave me at least some little progress over the original one: I now can ssh from the host to the guests.

But now I'm lost.

Offline

#2 2024-02-26 13:00:48

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,013

Re: Need help understanding Qemu/KVM/libvirt bridged networking

since you're using libvirt/virsh as frontend to manage things , you should stick to their documentation .

https://wiki.archlinux.org/title/Libvirt#Networking has an overview, make sure to follow the links it mentions (especially the first one in that section) .

Last edited by Lone_Wolf (2024-02-26 13:01:08)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2024-02-26 13:11:34

Markus.N2
Member
From: Germany
Registered: 2013-08-22
Posts: 99

Re: Need help understanding Qemu/KVM/libvirt bridged networking

Yes, this is one of the documents that confused me. It mentions eth1. But is eth1 an alias for the real device that according to the new naming convention is enp1s0 in my case?
Or is it another virtual device that has to be created first?

Reading it again, I noticed that I did not understand "physical" as "real". OK, that part is solved.

But setting enp1s0 as master for virbr0 disconnected the host from my LAN. I think I've read somewhere that this happens. That's not what I need. The host has only one physical network device, and it needs to stay connected while the guests having their own virtual connection.

Last edited by Markus.N2 (2024-02-26 13:27:13)

Offline

#4 2024-02-26 13:41:00

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,013

Re: Need help understanding Qemu/KVM/libvirt bridged networking

While it should be possible to do this with 1 card, the typical bridge setup assumes the bridge is on a 2nd / 3rd etc network card.

Using virtual ethernet interfaces is probably a better option for you . look at macvtap interfaces


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#5 2024-02-26 14:50:41

Markus.N2
Member
From: Germany
Registered: 2013-08-22
Posts: 99

Re: Need help understanding Qemu/KVM/libvirt bridged networking

I've just tried to add a macvtap interface and reconfigured my first guest to it. On starting, I've got a "Operation not permitted" error. Could be because the guest runs in the QEMU/KVM User session. Are there some limitations to macvtap in that regard?
Running in User session is another requirement I have to fulfill. I've read that the QEMU folks discourage using the User session, but in the end, the whole thing should be connected to the internet as server with the guests running separate services, and the server folks say "don't run VMs as root".

Offline

#6 2024-02-27 15:18:54

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,013

Re: Need help understanding Qemu/KVM/libvirt bridged networking

libirt & qemu don't run VMs as root, but with dedicated users/groups .

Not sure what the Qemu/KVM user session is, where do you select it ?

Please post the xml file created by libivrt for this guest.
Does the guest get to a (console) login prompt ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

Board footer

Powered by FluxBB