Learned about a new neat feature today:

In a network configuration you can add the following:

<network>
  <!-- ... -->
  <domain localonly="yes" name="virt" register="yes">
</domain></network>

This will allow addressing vms connected to that network via automatically-registered hostnames, for example for a VM with a ubuntu-test hostname, you should be able to access it from the host or any other VM on the same network as ubuntu-test.virt. Pretty neat if you don't want (or unable to, like my brain) memorize IP addresses.

  • name="virt" defines the shared part of the domain. Could be made up like in my example, could be a domain you own, such as workstation.nevkontakte.com.
  • localOnly="yes" configures libvirt-managed dnsmasq not to route non-existent domain queries to the external resolver. If you are using a made-up domain, you probably want this to be "yes", since external resolvers won't know anything about it anyway.
  • register="yes" automatically sets up your host's resolver so that you can access those domain names from the host. You can make it work without, but it's a nice quality of life feature, especially if you have several virtual networks in play.

Source: https://libvirt.org/formatnetwork.html#connectivity (scroll down to the "domain" section).