Over time there have been multiple solutions on how to get hosts to communicate with each other. Back in 2013 Dominic already wrote Automatic DNS updates from libvirt guests and the approach I’m taking here is a more automated way, taking advantage of developments in the Linux ecosystem since then.
For context, I’m using this on Fedora 44 but I expect it to work on any Linux. Make sure you’re using at least libvirt 10.1.
The first part is that your network needs to have a domain set up so libvirt will configure dnsmasq properly. If you already have a network, you can use virsh or virt-manager.
virsh net-edit default
Now make sure a domain entry with the right name exists:
This is enough for hosts to be able to resolve each other.
When using systemd-resolved on the host it also works there. You verify it by using resolvectl and looking at the DNS Servers and DNS Domain entries:
$ resolvectl status virbr0
Link 7 (virbr0)
Current Scopes: none
Protocols: -DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 192.168.122.1
DNS Domain: example.com
Default Route: no
Not sure what hook are you talking about, the DNS resolution works via dnsmasq and that seems to be a core feature of libvirt (I think). What RPM package your hook comes from?