Skip to main content
Topic: QEMU/KVM issues with dnsmasq (Read 691 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

QEMU/KVM issues with dnsmasq

Hi,

I'm not sure what is going on and not sure either how to debug this. I'm travelling tomorrow and I would really need to have my VM's network stack working while my host can also browse the internet. Basically, when I have my laptop on wired eth connection, QEMU networking works fine, but when I want to use the WiFi it doesn't work on both ends host/VM; dns queries don't get resolved, ping don't work and routing tables get messed up.

I have installed QEMU/KVM with virt-manager. One of the optional dependencies is dnsmasq so I also installed that, but is not working as it should. I've added libvirtd and dnsmasq to default runlevel on my OpenRC.

Code: [Select]
❯ sudo rc-service -l | grep -E "dns|libvirt"
dnsmasq
libvirt-guests
libvirtd
❯ sudo rc-status
Runlevel: default
 dbus                                                                                                                                                  [  started 00:07:06 (0) ]
 wpa_supplicant                                                                                                                                                    [  started  ]
 connmand                                                                                                                                              [  started 00:07:04 (0) ]
 dnsmasq                                                                                                                                                              [ failed ]
 libvirtd                                                                                                                                                          [  started  ]
 netmount                                                                                                                                                          [  started  ]
 postgresql                                                                                                                                                        [  started  ]
 local                                                                                                                                                             [  started  ]
 agetty.tty5                                                                                                                                           [  started 00:07:03 (0) ]
 agetty.tty6                                                                                                                                           [  started 00:07:03 (0) ]
 agetty.tty2                                                                                                                                           [  started 00:07:03 (0) ]
 agetty.tty4                                                                                                                                           [  started 00:07:03 (0) ]
 agetty.tty1                                                                                                                                           [  started 00:07:03 (0) ]
 agetty.tty3                                                                                                                                           [  started 00:07:03 (0) ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed/wanted
 virtlogd                                                                                                                                                          [  started  ]
Dynamic Runlevel: manual
 dnsmasq 

As you can see in the following snippet, the service goes up but hen some seconds later it goes down.

Code: [Select]
❯ sudo rc-service dnsmasq start; sudo rc-service dnsmasq status
 * Starting dnsmasq ...                                                                                                                                                   [ ok ]
 * status: started
❯ sudo rc-service dnsmasq status
 * status: stopped

Not sure if it's useful but here you have the xml config from the virt-manager virtual network I'm using.

Code: [Select]
<network>
  <name>default</name>
  <uuid>211064ca-5bc5-4243-add1-2519dfc3dbcf</uuid>
  <forward mode="nat">
    <nat>
      <port start="1024" end="65535"/>
    </nat>
  </forward>
  <bridge name="virbr0" stp="on" delay="0"/>
  <mac address="52:54:00:XX:XX:XX"/>
  <ip address="10.100.100.1" netmask="255.255.255.0">
    <dhcp>
      <range start="10.100.100.1" end="10.100.100.254"/>
    </dhcp>
  </ip>
</network>

Code: [Select]
❯ sudo pacman -Qi libvirt
Name            : libvirt
Version         : 1:10.0.0-3
Description     : API for controlling virtualization engines (openvz,kvm,qemu,virtualbox,xen,etc)
Architecture    : x86_64
URL             : https://libvirt.org/
Licenses        : LGPL-2.1-or-later  GPL-3.0-or-later
Groups          : None
Provides        : libvirt=10.0.0  libvirt.so=0-64  libvirt-admin.so=0-64  libvirt-lxc.so=0-64  libvirt-qemu.so=0-64
Depends On      : libpciaccess  yajl  fuse3  gnutls  parted  libssh  libxml2  numactl  polkit  libnbd  libnl
Optional Deps   : libvirt-storage-gluster: Gluster storage backend
                  libvirt-storage-iscsi-direct: iSCSI-direct storage backend
                  gettext: required for libvirt-guests.service [installed]
                  openbsd-netcat: for remote management over ssh [installed]
                  dmidecode: DMI system info support
                  dnsmasq: required for default NAT/DHCP for guests [installed]
                  radvd: IPv6 RAD support
                  iptables-nft: required for default NAT networking [installed]
                  qemu-desktop: QEMU/KVM support
                  qemu-emulators-full: Support of additional QEMU architectures
                  lvm2: Logical Volume Manager support [installed]
                  open-iscsi: iSCSI support via iscsiadm
                  swtpm: TPM emulator support
Required By     : libvirt-glib  libvirt-openrc  libvirt-python
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 46.01 MiB
Packager        : Artix Build Bot <[email protected]>
Build Date      : Wed 14 Feb 2024 07:45:53 AM CET
Install Date    : Sat 24 Feb 2024 02:31:39 PM CET
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature


Perhaps it's related but wpa_supplicant disables the SSID that I'm using at the moment trying to debug this. Also I want to mention I'm running too with dhcpcd, would that be causing any issues here?

Thanks in advance for your time and help!


Re: QEMU/KVM issues with dnsmasq

Reply #1
I don't use QEMU, but it should detect and use your system's default route and resolver. The dnsmasq helper is not required for QEMU's operation. Can you try bringing eth0 completely down when you're on wifi?

 

Re: QEMU/KVM issues with dnsmasq

Reply #2
I did not have exactly this issue. I'm using ethernet (at one point I was using a bridged interface, but that's probably not related). In my case I had VM's not getting IP's assigned. If I assigned manually then dns was failing, but pinging an ip like 1.1.1.1 worked. I was just using default kvm network at the time, nothing fancy.

For me I needed to add

firewall_backend = "iptables"

to /etc/libvirt/network.conf

And then it started working. (I also had my laptops dnsmasq service conflicting with qemus, but that might not be so relevant for you).

Anyway, hope it helps. I found the solution here https://bbs.archlinux.org/viewtopic.php?pid=2185232#p2185232