detecting whether a reserved lease is being issued for the first time

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

detecting whether a reserved lease is being issued for the first time

Afif Elghraoui
Hello,

I'm trying to use reserved leases in order to avoid hard-coding IP
addresses and manually managing them.

I have an action that I'd like to run the first time the IP address is
issued. I used an "on commit" statement, but I see that it gets run
every time the client boots and rebinds its address. Is there a good way
for the server to detect whether the IP address is issued for the first
time?

The client-state parameter seems to only be useful on the client side
and I didn't see any other option or statement that might be helpful for
this purpose.

Many thanks and regards
Afif

--
Afif Elghraoui | عفيف الغراوي
http://afif.ghraoui.name
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: detecting whether a reserved lease is being issued for the first time

Konstantin Stefanov
Hello.

On 18.11.2016 9:28, Afif Elghraoui wrote:
> I'm trying to use reserved leases in order to avoid hard-coding IP
> addresses and manually managing them.
>
> I have an action that I'd like to run the first time the IP address
> is issued. I used an "on commit" statement, but I see that it gets
> run every time the client boots and rebinds its address. Is there a
> good way for the server to detect whether the IP address is issued
> for the first time?
While I am not sure this is possible with isc-dhcpd, I'd suggest using
arpwatch for this purpose.

> The client-state parameter seems to only be useful on the client
> side and I didn't see any other option or statement that might be
> helpful for this purpose.

--
Konstantin Stefanov,

Research Computing Center
M.V Lomonosov Moscow State University
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: detecting whether a reserved lease is being issued for the first time

Afif Elghraoui


على الجمعـة 18 تشرين الثاني 2016 ‫01:52، كتب Konstantin Stefanov:
>> I have an action that I'd like to run the first time the IP address
>> > is issued. I used an "on commit" statement, but I see that it gets
>> > run every time the client boots and rebinds its address. Is there a
>> > good way for the server to detect whether the IP address is issued
>> > for the first time?
> While I am not sure this is possible with isc-dhcpd, I'd suggest using
> arpwatch for this purpose.
>

Many thanks for the suggestion. It looks like arpwatch has been
unmaintained for many years. I'll look into it to see if it's still
usable or if there is something else like it that works.

Many thanks and regards
Afif

--
Afif Elghraoui | عفيف الغراوي
http://afif.ghraoui.name
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: detecting whether a reserved lease is being issued for the first time

Simon Hobson
In reply to this post by Afif Elghraoui
Afif Elghraoui <[hidden email]> wrote:

> I have an action that I'd like to run the first time the IP address is
> issued. I used an "on commit" statement, but I see that it gets run
> every time the client boots and rebinds its address. Is there a good way
> for the server to detect whether the IP address is issued for the first
> time?

Is this an action that needs to be run exactly once, or can it be run multiple times without causing problems ?

But my main suggestion is to keep track of the action outside of DHCP. So when your on commit handler is called, check to see if you've already run the task and if so, then skip it.

Be aware that, unless it's changed, ISTR that the "on <action>" hooks need to run fast or they will block the server. So ideally your handler should do as little as possible (perhaps write some data to a signalling file ?) and then return - leaving any time consuming tasks to another process.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: detecting whether a reserved lease is being issued for the first time

Afif Elghraoui


على السبت 19 تشرين الثاني 2016 ‫01:18، كتب Simon Hobson:

> Afif Elghraoui <[hidden email]> wrote:
>
>> I have an action that I'd like to run the first time the IP address is
>> issued. I used an "on commit" statement, but I see that it gets run
>> every time the client boots and rebinds its address. Is there a good way
>> for the server to detect whether the IP address is issued for the first
>> time?
>
> Is this an action that needs to be run exactly once, or can it be run multiple times without causing problems ?
>
> But my main suggestion is to keep track of the action outside of DHCP. So when your on commit handler is called, check to see if you've already run the task and if so, then skip it.
>

Thanks, that's a great idea! I don't know why it never occurred to me.
I've made the commit handler idempotent and it seems to be working fine now.

> Be aware that, unless it's changed, ISTR that the "on <action>" hooks need to run fast or they will block the server. So ideally your handler should do as little as possible (perhaps write some data to a signalling file ?) and then return - leaving any time consuming tasks to another process.
>

Of course.

Many thanks and regards
Afif

--
Afif Elghraoui | عفيف الغراوي
http://afif.ghraoui.name
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users