Comment 12 for bug 1163147

Revision history for this message
Thomas Hood (jdthood) wrote : Re: can't resolve lan hosts (regression)

>> You need to configure things such that each nameserver listed in resolv.conf
>> can resolve all names you want resolved.

> This requirement feels impossible to meet; the dnsmasq spawned by libvirt
> on my laptop knows only the VMs running on my laptop. It is not possible
> for this dnsmasq to know the hosts on my LAN

That instance of dnsmasq, call it DV, provides services to VMs. If the VMs are going to access the LAN or the Internet then DV needs to forward DNS queries for which it isn't authoritative to a nameserver on the LAN or on the Internet.

> I have a standard consumer router on my network to provide DHCP
> and dynamic DNS services. I do not want to require my laptop to be
> on and connected to my LAN for other hosts to continue using the LAN.

Agreed. Your laptop should ultimately send DNS queries to the nameserver on the router, just as any other machine on the LAN does.

You want to be able to resolve VM names on your laptop as well as LAN and Internet names. In that case you will have to use DV as your laptop's nameserver and configure DV to forward DNS queries to the router and not use the nameserver that the laptop is using (which is DV itself — that would be a loop).

This should be implemented cleanly using resolvconf. Here is an outline of how that should be done, blindly assuming a few things such as that the "dnsmasq" package is not installed on your machine. I blindly assume, that is, that libvirt runs an instance of dnsmasq using the binary in the dnsmasq-base package.

Basically, DV should behave similarly to how the server instance of dnsmasq (from the "dnsmasq" package) behaves with respect to resolvconf.

1. DV should register with resolvconf a loopback address at which it listens.

Configure it to listen at 127.0.0.1 on the laptop and modify its control script to run

    echo "nameserver 127.0.0.1" | resolvconf -a lo.dnsmasq

on start and

    resolvconf -d lo.dnsmasq

on stop.

2. DV should have a hook script in /etc/resolvconf/update.d/ which generates a list of forwarders for DV to use. The resolvconf hook script from the dnsmasq package can be used verbatim for this purpose; simply put the file in update.d/ and configure DV to use /var/run/dnsmasq/resolv.conf as its only forwarders-list file. If you want details I can help you, or you can follow the good example of the dnsmasq package.