DNS in libvirt virtual machine

I recently made a dnsmasq server for my lan to resolve the ips of some servers. Since this was all I really wanted to do I just made the upstream dns my router. However, after starting up a libvirt vm, the dns stopped working. After adding some other upstream dns servers it started working. I don’t really have an issue with this but can’t seem to figure out why this is happening.
I am thinking that since the upstream was just my router there wasn’t much different with the routing, to before I added the dnsmasq server correct? Why would dns break in a vm without an alternate upstream dns than my router?

I suspect you have libvirt qemu networking in “simple pleb vm” mode where you don’t bother with networking setup and let qemu nat the VM and assign DHCP addresses and what happens is DHCP assignment in a VM messes up your dnsmasq, and works when you restart it.

Edit: actually, is your dnsmasq set to run at startup?

Can you make the VM bridged and type in the IP it’s supposed to have in VM config files and disable and DHCP client in the VM?

I don’t think VM network bridging is possible with libvirt. I have looked around and the best answer I could find was that it only works with ethernet.

dnsmasq on my system is not enabled, should it be?
I just followed the PCI Passthrough via OVMF Arch Wiki Article, for the libvirt setup. I haven’t really looked into any other methods for network setup with libvirt, would there be better methods?

What are you using if not ethernet?

I believe you need to setup the interface on your hypervisor as a bridge, then set the VM’s network interface as that bridge

Sorry, I misunderstood that the dnsmasq server that stopped working was being run in a VM and was flaky because of that.

It is - Networking - Libvirt Wiki has a bunch of detail on various “modes”. Underneath, chances are you’re probably just using qemu-kvm and have your pick of potential virtual devices to present within the VM, as well as qemu backends those virtual devices will be attached to on the host - usually some variant of a tap/macvtap interfaces configured one way or another on the host.


So where’s your dnsmasq running and what physical or virtual machines have their DNS broken?

Sorry, I haven’t been very specific. I have a baremetal server running dnsmasq. I run a few libvirt vms on my personal machine with gpu passthrough for gaming. After setting up the baremetal dnsmasq server, all of my libvirt virt manager vms started breaking. All of them spitting out dns errors, they would only resolve sites like google and bing sometimes. I thought I had fixed it by adding other upstream dns servers, besides my router.

Edit:
I got dns working in a standard vm, but it wouldn’t work in a gpu passthrough vm.

Update:
Everything is working again? I’m very confused.
I’m not having any issues at this point. Thank you.