Once configured, you’ll be able to talk to libvirtd VM’s using their hostname, rather than having to know the IP address.

Forward DNS requests to libvirt’s Domain

Libvirt uses it’s own built-in dnsmasq instance for serving DHCP and DNS to the VM’s in the virtual network.

We’ll configure NetworkManager’s dnsmasq to forward requests to the libvirt instance.



Now when we try to access hostname.vm, we’ll be forwarded to (the IP for libvirt’s default virtual network DHCP server).

When testing with terraform, usign the libvirt provider, I create a terraform specific virtual network. So I have server=/terraform.vm/ included in this config file (hostname.terraform.vm).

Configuring libvirt

Now we need to configure libvirt so that it resolves DNS requests with this domain name.

Either using the XML editor in virt-manager or virsh --connect qemu:///system net-edit default:

  <forward mode='nat'>
      <port start='1024' end='65535'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:51:bd:3f'/>
  <!-- Add this line -->
  <domain name='vm' localOnly='yes'/>
  <ip address='' netmask=''>
      <range start='' end=''/>