[Dnsmasq-discuss] Reg: --dhcp-script option

Nehal J Wani nehaljw.kkd1 at gmail.com
Mon Dec 16 21:49:37 GMT 2013


On 12/17/13, Simon Kelley <simon at thekelleys.org.uk> wrote:
> On 16/12/13 21:26, Nehal J Wani wrote:
>> Is the environment variable DNSMASQ_INTERFACE set when "del" action is
>> called? If not, why?
>
> It _may_ be, if the interface associated with the lease is known. That
> information is not stored in the lease file, so restarting dnsmasq will
> lose the knowledge of the interface and DNSMASQ_INTERFACE will not be
> set, unless there's an intervening event that provides the information.
>
> So
>
> <restart dnsmasq>
> <renew DHCP lease>
> <DHCP lease expires>
> <del event sent>
>
> will set DNSMASQ_INTERFACE
>
> but
>
> <stop dnsmasq>
> <wait whilst lease expires>
> <start dnsmasq>
> <dnsmasq notices that lease has expired and sends del event>
>
> won't.
>
> This is also true of many of the other data supplied, eg
> DNSMASQ_VENDOR_CLASS, DNSMASQ_SUPPLIED_HOSTNAME, DNSMASQ_CIRCUIT_ID
>
> Cheers,
>
>
> Simon.
>
>
>
>
>>
>> On 12/17/13, Simon Kelley <simon at thekelleys.org.uk> wrote:
>>> On 16/12/13 19:06, Nehal J Wani wrote:
>>>> Suppose I am using the script for dnsmasq lease-change hook
>>>> ([dnsmasq.git] / contrib / mactable / macscript) and 3 leases have
>>>> been handed out for a particular network. Now, if I shutdown the
>>>> network and start dnsmasq again after these 3 leases have expired, the
>>>> leases file has zero entries, but the "/tmp/dnsmasq-ip-mac.status"
>>>> file will have those old entries. How will I clean them up? Will I
>>>> have to manually check the timestamps and remove those entries or
>>>> dnsmasq provides something that I am missing?
>>>>
>>>
>>> You'll see "del" events for the leases, either when they actually
>>> expire, or (if dnsmasq isn't running then) when dnsmasq is started
>>> again.
>>>
>>>
>>> Cheers,
>>>
>>> Simon.
>>>
>>>
>>> _______________________________________________
>>> Dnsmasq-discuss mailing list
>>> Dnsmasq-discuss at lists.thekelleys.org.uk
>>> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
>>>
>>
>>
>
>

Actually, while developing the leases API for libvirt, I have to keep
separate custom-leases file for each network. (One active network is
mapped to one interface only) So, I thought, why not use the env
DNSMASQ_INTERFACE to differentiate? I have attached the source code of
script. The problem arises during:
<restart dnsmasq>
<renew DHCP lease>
<DHCP lease expires>
<del event sent>
Now, since the interface is not known, I'll have to compare IP address
in each file! Is there no way of knowing which file it should
correspond to?

I want to keep leases in different files to ease my task, so that once
a network is completely destroyed and undefined, its leases can also
be deleted easily (by just using unlink() on the desired file).

-- 
Nehal J Wani
-------------- next part --------------
A non-text attachment was scrubbed...
Name: leaseshelper.c
Type: text/x-csrc
Size: 5525 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20131217/fa353271/attachment.c>


More information about the Dnsmasq-discuss mailing list