[Dnsmasq-discuss] dumping current dhcp leases without always updating the leasefile curing normal ?
simon at thekelleys.org.uk
Mon Oct 14 17:42:55 BST 2013
On 11/10/13 16:37, Rick Jones wrote:
> On 10/11/2013 07:16 AM, Simon Kelley wrote:
>> On 11/10/13 01:39, Rick Jones wrote:
>>> I am still on the steep learning slope for dnsmasq. The manpage lists a
>>> -l/--dhcp-leasefile option into which dnsmasq will store lease
>>> information. I gather though that it will be updating that all the time
>>> as leases come and go.
>>> Is there a version post 2.59 where one can send dnsmasq a signal to
>>> cause it to dump a copy of its current lease information to a file, but
>>> without the continuous updates in normal operation?
>> No. there's a mode meant for use on flash filesystems that updates the
>> lease file less often, if that helps.
> It might actually. I'll try to take a look at it.
>> See also this thread
> From that I should take away that the lease file format is not fixed
> and there but for the grace of the developers go I should I start
> grubbing through it, yes? I can accept that.
>> More context about what youre trying to achieve would help.
> What I would like to be able to do is "know" (make an informed guess)
> which of the clients which could have a lease probably have a lease (or
> probably do not have a lease), but in an environment where I might have
> either rather busy dnsmasq processes, or a large number of individually
> not very busy dnsmasq processes and want to minimize the storage load.
> But I don't need to know all the time, just occasionally and not
> necessarily on a schedule and not necessarily all the dnsmasq processes.
> So, I figured some sort of "dump your current leases" feature would
> satisfy that.
> I cannot really rely on the clients being willing to respond to the
> likes of ping, they may only respond to things they've initiated
> themselves. I also do not have other access to the clients (eg their
> console). So, all I can think of presently is trying to ask the dnsmasq
> process(es) what it believes its active leases happen to be.
> BTW, sorry about botching the last part of the subject there.
You could achieve the two aims "minimise storage load" and "know about
dnsmasq leases" by implementing the lease database in some sort of
lightweight database. Dnsmasq is designed so it can be without a lease
file completely. At startup you prime the in-memory copy of the lease
database via a DHCP-script "init" call, and then whilst dnsmasq is
running is makes calls to the DHCP script as the data changes which can
be used to update the database.
More information about the Dnsmasq-discuss