Did some more testing (found how to adjust libvirts dnsmasq.conf and
restart it to pick up conf changes):

To test, get the dnsmasq pid using the vagrant-libvirt.conf config and check 
the environment set for the process with:
sudo cat /proc/2586/environ
VIR_BRIDGE_NAME=virbr0

After killing the relevant dnsmasq you can manually restart using
sudo VIR_BRIDGE_NAME=virbr0 /usr/sbin/dnsmasq 
--conf-file=/var/lib/libvirt/dnsmasq/vagrant-libvirt.conf --leasefile-ro 
--dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper

Just make sure to check the environment for the dnsmasq process before

Adding entries with the following format to the libvirt dnsmasq.conf:
host-record=<short>,<fqdn>,<ip>
interface-name=<short>,br0

And have entries with the following format in /etc/hosts
127.0.0.1 localhost
127.0.1.1 <fqdn> <short>

and nslookup and dig returns the configured <ip> for both short and fqdn
instead of 127.0.1.1 as it used to.

It appears that host-record overrides entries read from hosts-files
because record options are considered to be read before host-files, and
only the first entry results in the PTR creation, so a name appearing in
the host-record inhibits PTR-record creation based on the entries in
/etc/hosts.

I also tried using:
host-record=<fqdn>,<ip>
host-record=<short>,<ip>

Basically without the interface-name being specified and dig/nslookup
would start returning two records. So it means that 'interface-
name=<short>,br0' appears to be required to prevent the short version
from returning both records.


It would seem that the alternative would be to create a local copy of 
/etc/hosts pruned of all loop back address entries and provide that as the 
hosts file to read instead.

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to lxc in Ubuntu.
https://bugs.launchpad.net/bugs/1326536

Title:
  libvirt's dnsmasq setup will read /etc/hosts on the host, resulting in
  odd resolution behaviour on the VM

Status in libvirt package in Ubuntu:
  Triaged
Status in lxc package in Ubuntu:
  Triaged

Bug description:
  When libvirt configures / starts up dnsmasq on the host, it does not
  pass --no-hosts, resulting in it reading in the /etc/hosts file from
  the host.

  The default ubuntu setup will have the host's hostname in /etc/hosts
  under 127.0.1.1. Since libvirt's dnsmasq is reading this file,
  anything querying that dnsmasq instance will resolve the host's
  hostname out of /etc/hosts.

  The result of this is any VM running on the host will resolve the
  host's hostname as 127.0.1.1. For example, if the host's hostname is
  BoxA, any VM running on the host will resolve BoxA to 127.0.1.1, which
  is not BoxA's actual address.

  Would recommend passing --no-hosts to dnsmasq when libvirt starts it
  up. If a user wants hardcoded hosts for their libvirt network, they
  can add them to /var/lib/libvirt/dnsmasq/default.addnhosts . If this
  is an acceptable solution, I'd be happy to write the patch up.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1326536/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to