[libvirt-users] Changing dnsmasq DNS settings for virtual machines

Laine Stump laine at laine.org
Sun Apr 13 14:13:58 UTC 2014

On 04/10/2014 08:12 PM, Johannes Kastl wrote:
> Hash: SHA1
> On 10.04.2014 13:08 Laine Stump wrote:
>> On 04/06/2014 08:33 AM, Johannes Kastl wrote:
>>> There was a bug in libvirt for quite awhile that caused 
>>> locally-unresolved requests for hostnames in the domain given by
>>> the network's <domain name='xyzzy'/> element to be dropped rather
>>> than forwarded. Is that possibly the cause of your problems?
> Maybe...
>>> Alternately, since 1.1.3 you can tell dnsmasq to forward to a
>>> specific address rather than the one listed in /etc/resolv.conf
>>> with the <forwarder> subelement of the <dns> element in the
>>> network definition, e.g.:
>>> <dns> <forwarder addr=''/> </dns>
> Nice, seems to work.
>>> This is documented here:
>>> http://www.libvirt.org/formatnetwork.html#elementsAddress
> I actually was on that page, but I must have missed that bit...
>> Which brings me to the next question: How to set the addn-hosts=
>> for the libvirtd-dnsmasq in the xml file?
>>> You do that with the <host> subelement of the <dns> element. An
>>> example is at the same link as above.
> No, thats not it. I do not want to set single hosts, I want to tell
> dnsmasq to read an additional hosts-file.

There is no provision for that. If you want additional hosts to be known
by the libvcirt instance of dnsmasq, you must enter them into the xml.
If we allowed pointing to an existing addn-hosts file written by the
user, we would be adding the format of dnsmasq's addn-hosts file to
libvirt's official API, which we don't want to do - we want to keep
libvirt's API as implementation-agnostic as possible (in case someone
implements a libvirt network driver that uses something other than
dnsmasq for DNS, for example).

>  In the normal dnsmasq.conf
> this is done via addn-hosts=, and that appears in the conf-file for
> the network called e.g. WHATEVER:
> addn-hosts=/var/lib/libvirt/dnsmasq/WHATEVER.addnhosts

More information about the libvirt-users mailing list