[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] Making DHCP leases available to local DNS server through dnsmasq



Yes, except that it does not work. As you can see below, libnss-libvirt is installed and configured, but the VM "KVM-Ubuntu-GNS3-Server-17.04" is not reachable through its DNS name.

# apt-cache policy libnss-libvirt
libnss-libvirt:
  Installed: 3.0.0-4
...
# cat /etc/nsswitch.conf 
passwd:         compat
group:          compat
shadow:         compat

hosts: files libvirt libvirt_guest mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
   Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-06-16 11:44:59 CEST; 11min ago
     Docs: man:libvirtd(8)
           http://libvirt.org
 Main PID: 9448 (libvirtd)
      CPU: 1.790s
   CGroup: /system.slice/libvirtd.service
           ├─ 5556 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/virtual-mgt-5.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
           ├─ 5557 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/virtual-mgt-5.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
 ...
           ├─ 8805 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
           ├─ 8806 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
           ├─ 9448 /usr/sbin/libvirtd
           └─15116 qemu-system-x86_64 -enable-kvm -name guest=KVM-Ubuntu-GNS3-Server-17.04,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/

...
Jun 16 11:55:14 samsung-ubuntu dnsmasq-dhcp[8805]: DHCPREQUEST(virbr0) 192.168.122.124 52:54:00:03:9f:9f
Jun 16 11:55:14 samsung-ubuntu dnsmasq-dhcp[8805]: DHCPACK(virbr0) 192.168.122.124 52:54:00:03:9f:9f KVM-Ubuntu-GNS3-Server-17
# ping KVM-Ubuntu-GNS3-Server-17.04
ping: KVM-Ubuntu-GNS3-Server-17.04: Name or service not known
# ping KVM-Ubuntu-GNS3-Server-17.04.actionmystique.net
ping: KVM-Ubuntu-GNS3-Server-17.04.actionmystique.net: Name or service not known
# ping 192.168.122.124
PING 192.168.122.124 (192.168.122.124) 56(84) bytes of data.
64 bytes from 192.168.122.124: icmp_seq=1 ttl=64 time=0.181 ms
64 bytes from 192.168.122.124: icmp_seq=2 ttl=64 time=0.165 ms

A few possible explanations for that issue are:
- something is not configured correctly
- there is an incompatibility with NetworkManager
- there is a bug with libnss-libvirt
- I'm missing something

On Fri, Jun 16, 2017 at 10:49 AM, Michal Privoznik <mprivozn redhat com> wrote:
On 06/10/2017 08:53 PM, jean-christophe manciot wrote:
> Hello everyone,
>
> I have multiple virtual networks defined on my Server:
> # virsh net-list --all
>  Name                 State      Autostart     Persistent
> ----------------------------------------------------------
>  default              active     yes           yes
> ...
>  virtual-mgt-5        active     yes           yes
>  ...
>
> When a VM is started on one of them with an interface which needs the
> dnsmasq DHCP server to get its IP address/len, it remains inaccessible with
> the FQDN once the IP information is acquired.
>
> The default values are used for each dnsmasq instance:
> ● libvirtd.service - Virtualization daemon
>    Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor
> preset: enabled)
>    Active: active (running) since Sat 2017-06-10 19:48:58 CEST; 3ms ago
>      Docs: man:libvirtd(8)
>            http://libvirt.org
>  Main PID: 25365 (libvirtd)
>     Tasks: 35 (limit: 4915)
>    Memory: 27.1M
>       CPU: 28ms
>    CGroup: /system.slice/libvirtd.service
>            ├─22262 /usr/sbin/dnsmasq
> --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro
> --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
>            ├─22263 /usr/sbin/dnsmasq
> --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro
> --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
> ...
>            ├─24061 /usr/sbin/dnsmasq
> --conf-file=/var/lib/libvirt/dnsmasq/virtual-mgt-5.conf --leasefile-ro
> --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
>            ├─24062 /usr/sbin/dnsmasq
> --conf-file=/var/lib/libvirt/dnsmasq/virtual-mgt-5.conf --leasefile-ro
> --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
> ...
>            ├─25365 /usr/sbin/libvirtd
>            └─25384 /usr/sbin/dnsmasq --help
>
> I wonder whether the option "--leasefile-ro" gets in the way or not: there
> must be a key=value in /etc/libvirt/qemu/networks/<virtual_network>.xml to
> enable this behavior, but could not find it in the Network XML format
> <https://libvirt.org/formatnetwork.html>.

The --leasefile-ro argument is added unconditionally, just like
--dhcp-script. If you want to do name translation, either have static IP
addresses and edit the hosts file, or use NSS module:

https://libvirt.org/nss.html

Michal



--
Jean-Christophe

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]