[Dnsmasq-discuss] Reading the dhcp.leases file

Reddeiah Raju Konduru raju39k at gmail.com
Tue Feb 14 18:48:05 GMT 2017


Hi Simon,

Thanks for the DHCP Client-ID's patch.

- Raju



On Tue, Feb 14, 2017 at 7:10 AM, Simon Kelley <simon at thekelleys.org.uk>
wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Albert's suggestions are good, and you can't reliably read the leases
> file - in gets modified by delete-and-rewrite, so if the timing is
> wrong, you'll see an incomplete write.
>
> DHCP script gets all the information needed to maintain a database
> equivalent to the leases file, using whatever engine you prefer.
>
>
>
> Cheers,
>
> Simon.
>
>
> On 12/02/17 05:53, Albert ARIBAUD wrote:
> > Hi Sam,
> >
> > Le Sat, 11 Feb 2017 16:06:55 -0600 Sam Weber <samweber01 at 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
> > resolution process.
> >
> > - 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)
> >
> > Amicalement,
> >
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.22 (GNU/Linux)
>
> iQIcBAEBCAAGBQJYox3bAAoJEBXN2mrhkTWiO7gP/0fTR+9xbNPupk1pDBbE/Y90
> 5XQ5/LnS++uqhfUYBL8UPzjqk+l1PpKKb3nvTlGGQ/Ul68UsZ968awQbvZQgFy0l
> 5WxrLyzTHnKLKzksII2ZKOGjOZ/fvU3+USHyPo6hgfKSQbCfV9+LyW3vYLBGfFMW
> n84r6mCzeUSLTOAwzXk813x7z5suHaNs3Rhc0lxHUTI/Lim4Lvg9oJE6yKAP3pqY
> YE7BhOvtIbGKx3JGrWoy6EyAvSzirci2b5Kol+gJ+rCi7TvTqUP5BdvLY0QLYdbY
> BS7l4xxR8DWNJCrgwa+VMnEMeYIlSZ9vlkWBnGiw++ksI0M4K9C3kWAmIM0/Anfv
> fBNGtjV4SsOlpydBbuQmizkZQty3NiWo1XqcGlPOS/0YVQhrLqyTBFmCbovLs0LU
> v43Iqj2z01XcP+znD/FDlY41kgC3UHJPKR/1RhL966Yz7ZkHyl9d4unV2B69OLCE
> gjN3HahWa8j9RJ7Y8rXmJeUbN7UPnZWuWUwR0dgid6qUMfnlo3EQniBbbNQW6Fso
> EpB9N2R2npTs3cTitAJiE536Y+0jv0ICsX7GJUaWLxGGhqKmDxBQrF8V0sX1pO2g
> 5it7PWOY1cNONqG05QXlSsf83IMogOPlajEok6vKcsUSg/oy38HqH29UiW/fOr8N
> WSvLT3mkikRqFv9hkCXZ
> =Qo5a
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
>



-- 
Thanks & Regards,

Reddeiah Raju Konduru
+918095133903
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20170214/1daa70ab/attachment-0001.html>


More information about the Dnsmasq-discuss mailing list