Le Sat, 11 Feb 2017 16:06:55 -0600
Sam Weber <samwebe...@gmail.com> a écrit:
> In our system, when a change occurs to the DNS entries we want
> dnsmasq to respond to, we scan the directory of active entries and
> then grep the dhcp.leases file to see if the entry exists there. If
> the entry is not found in the leases file, we omit it. Once the scan
> and check is completed, we write a new hosts file and then send
> SIGHUP to dnsmasq so it knows to read the new file. This works well
> most of the time. Sometimes, however, a perfectly valid entry is not
> found in the dhcp.leases file so we incorrectly omit the entry from
> the dnsmasq hosts file. We can see that the leases file gets written
> very often in our system, and we think that sometimes we must be
> reading the leases file whilst dnsmasq is writing it, resulting in
> our reading the file when a value of interest has not yet been
> written. Is this idea of our sometimes reading an incomplete leases
> file a possibility? Is there a workaround other than reading the
> leases file several times?
Not sure I understand your problem right, so I'll rephrase it and let
you tell me if that's what you do and want to happen:
- you have a list of names associated with IP addresses;
- you want to filter this list, keeping only the entries where the IP
address is currently being leased;
- you want the filtered list to be used by dnsmasq in its name
- you want the list to be kept up to date with the current leases.
- IOW, you want DHCP clients that get an IP which appears in your
list one to be assigned the corresponding name in the DNS, and you
want the DNS to NOT map names in this list if the corresponding
IP is not leased right now.
Is that it?
If so, /maybe/ dhcp-script is what you need or at least can help you
detect when you need to run your update, as it would give you a sign
that the leases just changed.
But it seems to me what you are doing is not really different from
what dnsmasq already does (i.e. reflexting DHCP names into the DNS) when
the MAC-to-IP mapping is done with static leases and each dhcp-host line
specifies a name.
If this is indeed what you are doing, then maybe you can achieve that
with options dhcp-hostsfile and dhcp-ignore-names.
You'd use dhcp-hostsfile to point to your list written as a list of
dhcp-host options, minus the "dhcp-host=" prefix.
You'd specify dhcp-ignore-names to make sure no host can overrule your
list and choose its own name in its DHCP requests.
You would then only have to tell dnsmasq whenever your list changes by
sending it SIGHUP, but you would not have to care about DHCP leases
being granted or released, as that is automatically reflected in the
DNS part of dnsmasq.
HTH (again, IIUC)
Dnsmasq-discuss mailing list