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

jean-christophe manciot actionmystique at gmail.com
Fri Jun 16 12:38:21 UTC 2017


>
> libvirt-nss is not for translating DNS names, rather than libvirt guest
> names


I meant hostname/guest name. There is no static DNS in /etc/hosts for the
VMs and no specific records in DNS server.

Can you see the guest in: /var/lib/libvirt/dnsmasq/virbr0.{macs,status}
>

 # cat /var/lib/libvirt/dnsmasq/virbr0.{macs,status}
[
  {
    "domain": "KVM-Ubuntu-GNS3-Server-17.04",
    "macs": [
      "52:54:00:03:9f:9f"
    ]
  }
]
[
  {
    "ip-address": "192.168.122.124",
    "mac-address": "52:54:00:03:9f:9f",
    "hostname": "KVM-Ubuntu-GNS3-Server-17",
    "expiry-time": 1497617966
  }
]

You need to restart the network after you've set up the NSS module.


I've rebooted the system.

I am using something along the lines of:


>  $ cat /etc/dnsmasq.d/libvirt.conf

 server=/virt/192.168.213.1

 server=/213.168.192.in-addr.arpa/192.168.213.1/


I have no /etc/dnsmasq.d/libvirt.conf, but in */etc/dnsmasq.conf*:
*local=/actionmystique.net/ <http://actionmystique.net/>*

I thought this would add that domain name to the answers from whatever is
found in DHCP leases.
The comment says:
# Add local-only domains here, queries in these domains are answered
# from /etc/hosts or DHCP only.
Since the first libvirt-nss module ("libvirt" plugin) looks into DHCP
server leases, the above setting should work, shouldn't it?

Actually, I've just realized that there is a discrepancy between the
libvirt VM guest name and the Ubuntu hostname, where the trailing ".04" has
been automatically removed.
So, the* hostname (not guest name) is accessible*:
# ping KVM-Ubuntu-GNS3-Server-17
PING KVM-Ubuntu-GNS3-Server-17 (192.168.122.124) 56(84) bytes of data.
64 bytes from KVM-Ubuntu-GNS3-Server-17 (192.168.122.124): icmp_seq=1
ttl=64 time=0.191 ms
64 bytes from KVM-Ubuntu-GNS3-Server-17 (192.168.122.124): icmp_seq=2
ttl=64 time=0.302 ms
...
*but not he FQDN*:
# ping KVM-Ubuntu-GNS3-Server-17.actionmystique.net
ping: KVM-Ubuntu-GNS3-Server-17.actionmystique.net: Name or service not
known

On Fri, Jun 16, 2017 at 1:39 PM, Martin Kletzander <mkletzan at redhat.com>
wrote:

> On Sat, Jun 10, 2017 at 08:53:16PM +0200, 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
>> ...
>>
>>
> I am using something along the lines of:
>
>  $ cat /etc/dnsmasq.d/libvirt.conf
>  server=/virt/192.168.213.1
>  server=/213.168.192.in-addr.arpa/192.168.213.1/
>
> And all guests have .virt in their hostname, so I'm at least able to use
> that.  That way guests are available by their names in the .virt
> domain.  You should be able to do that with your domain name as well.
> Let me know if that works for you or not.
>
> Have a nice day,
> Martin
>



-- 
Jean-Christophe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170616/80410ce5/attachment-0001.htm>


More information about the libvir-list mailing list