Logging DHCP lease duration in seconds

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

Logging DHCP lease duration in seconds

Alp Eren Kose
Hi,

I have an easy question I believe, I want to log DHCP lease durations given to clients, I tried the following, however it appears most of the time, logs are showing half of the lease duration.

log(info, concat( "IP: ", binary-to-ascii(10, 8, ".", leased-address), " ; ", "leasetime:", binary-to-ascii(10,32,"",encode-int(lease-time,32)) ));

I have set the following lease time values for a pool:

subnet 172.16.2.0 netmask 255.255.255.0 {
  option routers 172.16.2.1;
  pool {
    failover peer "failover-partner";
    default-lease-time 300;
    min-lease-time 300;
    max-lease-time 300;
    range 172.16.2.10 172.16.2.250;
  }
}

And this configuration produces an output like this:

Oct  2 14:34:44 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
Oct  2 14:37:10 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
Oct  2 14:37:13 mercan dhcpd: IP: 172.16.2.127 ; leasetime:297
Oct  2 14:39:37 mercan dhcpd: IP: 172.16.2.127 ; leasetime:156
Oct  2 14:42:03 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
Oct  2 14:44:28 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
Oct  2 14:46:53 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
Oct  2 14:49:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
Oct  2 14:49:54 mercan dhcpd: IP: 172.16.2.127 ; leasetime:264
Oct  2 14:50:47 mercan dhcpd: IP: 172.16.2.127 ; leasetime:247
Oct  2 14:51:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:269

How can log the precise lease durations, would be great if anyone has any suggestions?

Thanks in advance.
Alp


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

RE: Logging DHCP lease duration in seconds

Denis Laventure

The client will renew the lease at half the max-lease-time. So seeing 150 sec for a 300 sec lease seems normal.

 

Hi,

 

I have an easy question I believe, I want to log DHCP lease durations given to clients, I tried the following, however it appears most of the time, logs are showing half of the lease duration.

 

log(info, concat( "IP: ", binary-to-ascii(10, 8, ".", leased-address), " ; ", "leasetime:", binary-to-ascii(10,32,"",encode-int(lease-time,32)) ));

 

I have set the following lease time values for a pool:

 

subnet 172.16.2.0 netmask 255.255.255.0 {

  option routers 172.16.2.1;

  pool {

    failover peer "failover-partner";

    default-lease-time 300;

    min-lease-time 300;

    max-lease-time 300;

    range 172.16.2.10 172.16.2.250;

  }

}

 

And this configuration produces an output like this:

 

Oct  2 14:34:44 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155

Oct  2 14:37:10 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154

Oct  2 14:37:13 mercan dhcpd: IP: 172.16.2.127 ; leasetime:297

Oct  2 14:39:37 mercan dhcpd: IP: 172.16.2.127 ; leasetime:156

Oct  2 14:42:03 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154

Oct  2 14:44:28 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155

Oct  2 14:46:53 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155

Oct  2 14:49:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155

Oct  2 14:49:54 mercan dhcpd: IP: 172.16.2.127 ; leasetime:264

Oct  2 14:50:47 mercan dhcpd: IP: 172.16.2.127 ; leasetime:247

Oct  2 14:51:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:269

 

How can log the precise lease durations, would be great if anyone has any suggestions?

 

Thanks in advance.

Alp

 


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

RE: Logging DHCP lease duration in seconds

glenn.satchell
Hi Alp

lease-time shows the remaining time in the lease, not the total time.

This is from the dhcp-eval man page:

     lease-time

       The duration of the current lease - that is,  the  differ-
       ence  between the current time and the time that the lease
       expires.

regards,
-glenn

On Sat, October 3, 2015 6:51 am, Denis Laventure wrote:

> The client will renew the lease at half the max-lease-time. So seeing 150
> sec for a 300 sec lease seems normal.
>
> Hi,
>
> I have an easy question I believe, I want to log DHCP lease durations
> given to clients, I tried the following, however it appears most of the
> time, logs are showing half of the lease duration.
>
> log(info, concat( "IP: ", binary-to-ascii(10, 8, ".", leased-address), " ;
> ", "leasetime:", binary-to-ascii(10,32,"",encode-int(lease-time,32)) ));
>
> I have set the following lease time values for a pool:
>
> subnet 172.16.2.0 netmask 255.255.255.0 {
>   option routers 172.16.2.1;
>   pool {
>     failover peer "failover-partner";
>     default-lease-time 300;
>     min-lease-time 300;
>     max-lease-time 300;
>     range
172.16https://www.dibbssm.net/GroupFiles/Group167/Documents/Cubs/E1_Cub_Fun_In_the_Snow.pdf.2.10
172.16.2.250;

>   }
> }
>
> And this configuration produces an output like this:
>
> Oct  2 14:34:44 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:37:10 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
> Oct  2 14:37:13 mercan dhcpd: IP: 172.16.2.127 ; leasetime:297
> Oct  2 14:39:37 mercan dhcpd: IP: 172.16.2.127 ; leasetime:156
> Oct  2 14:42:03 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
> Oct  2 14:44:28 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:46:53 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:49:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:49:54 mercan dhcpd: IP: 172.16.2.127 ; leasetime:264
> Oct  2 14:50:47 mercan dhcpd: IP: 172.16.2.127 ; leasetime:247
> Oct  2 14:51:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:269
>
> How can log the precise lease durations, would be great if anyone has any
> suggestions?
>
> Thanks in advance.
> Alp
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users


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

Re: Logging DHCP lease duration in seconds

Alp Eren Kose
Oh I see, that made it more clear, however I still didn't understand a point. At renewal time, the client takes another full lease duration right, so I would still expect to see the full duration?

Perhaps is there anyway that I can log the lease end time or duration at each request? I know I can get this at the leases file, however I need to log that.

Thanks a lot,
Alp

On Sun, Oct 4, 2015 at 3:47 PM, Glenn Satchell <[hidden email]> wrote:
Hi Alp

lease-time shows the remaining time in the lease, not the total time.

This is from the dhcp-eval man page:

     lease-time

       The duration of the current lease - that is,  the  differ-
       ence  between the current time and the time that the lease
       expires.

regards,
-glenn

On Sat, October 3, 2015 6:51 am, Denis Laventure wrote:
> The client will renew the lease at half the max-lease-time. So seeing 150
> sec for a 300 sec lease seems normal.
>
> Hi,
>
> I have an easy question I believe, I want to log DHCP lease durations
> given to clients, I tried the following, however it appears most of the
> time, logs are showing half of the lease duration.
>
> log(info, concat( "IP: ", binary-to-ascii(10, 8, ".", leased-address), " ;
> ", "leasetime:", binary-to-ascii(10,32,"",encode-int(lease-time,32)) ));
>
> I have set the following lease time values for a pool:
>
> subnet 172.16.2.0 netmask 255.255.255.0 {
>   option routers 172.16.2.1;
>   pool {
>     failover peer "failover-partner";
>     default-lease-time 300;
>     min-lease-time 300;
>     max-lease-time 300;
>     range
172.16https://www.dibbssm.net/GroupFiles/Group167/Documents/Cubs/E1_Cub_Fun_In_the_Snow.pdf.2.10
172.16.2.250;
>   }
> }
>
> And this configuration produces an output like this:
>
> Oct  2 14:34:44 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:37:10 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
> Oct  2 14:37:13 mercan dhcpd: IP: 172.16.2.127 ; leasetime:297
> Oct  2 14:39:37 mercan dhcpd: IP: 172.16.2.127 ; leasetime:156
> Oct  2 14:42:03 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
> Oct  2 14:44:28 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:46:53 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:49:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:49:54 mercan dhcpd: IP: 172.16.2.127 ; leasetime:264
> Oct  2 14:50:47 mercan dhcpd: IP: 172.16.2.127 ; leasetime:247
> Oct  2 14:51:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:269
>
> How can log the precise lease durations, would be great if anyone has any
> suggestions?
>
> Thanks in advance.
> Alp
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


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

Re: Logging DHCP lease duration in seconds

Bob Harold

On Sun, Oct 4, 2015 at 3:47 PM, Glenn Satchell <[hidden email]> wrote:
Hi Alp

lease-time shows the remaining time in the lease, not the total time.

This is from the dhcp-eval man page:

     lease-time

       The duration of the current lease - that is,  the  differ-
       ence  between the current time and the time that the lease
       expires.

regards,
-glenn

On Sat, October 3, 2015 6:51 am, Denis Laventure wrote:
> The client will renew the lease at half the max-lease-time. So seeing 150
> sec for a 300 sec lease seems normal.
>
> Hi,
>
> I have an easy question I believe, I want to log DHCP lease durations
> given to clients, I tried the following, however it appears most of the
> time, logs are showing half of the lease duration.
>
> log(info, concat( "IP: ", binary-to-ascii(10, 8, ".", leased-address), " ;
> ", "leasetime:", binary-to-ascii(10,32,"",encode-int(lease-time,32)) ));
>
> I have set the following lease time values for a pool:
>
> subnet 172.16.2.0 netmask 255.255.255.0 {
>   option routers 172.16.2.1;
>   pool {
>     failover peer "failover-partner";
>     default-lease-time 300;
>     min-lease-time 300;
>     max-lease-time 300;
>     range
172.16https://www.dibbssm.net/GroupFiles/Group167/Documents/Cubs/E1_Cub_Fun_In_the_Snow.pdf.2.10
172.16.2.250;
>   }
> }
>
> And this configuration produces an output like this:
>
> Oct  2 14:34:44 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:37:10 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
> Oct  2 14:37:13 mercan dhcpd: IP: 172.16.2.127 ; leasetime:297
> Oct  2 14:39:37 mercan dhcpd: IP: 172.16.2.127 ; leasetime:156
> Oct  2 14:42:03 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
> Oct  2 14:44:28 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:46:53 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:49:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:49:54 mercan dhcpd: IP: 172.16.2.127 ; leasetime:264
> Oct  2 14:50:47 mercan dhcpd: IP: 172.16.2.127 ; leasetime:247
> Oct  2 14:51:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:269
>
> How can log the precise lease durations, would be great if anyone has any
> suggestions?
>
> Thanks in advance.
> Alp

Reading the man pages, try replacing:
     lease-time
with:
      config-option dhcp-lease-time

But do some packet traces to be sure that it truly gives the lease time in the first ack packet, which might be the mclt instead of the normal lease time if failover is used.

I would like to try it myself sometime when I get a chance.

-- 
Bob Harold


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

Re: Logging DHCP lease duration in seconds

Alp Eren Kose
Thank you very much, I have tried that with no luck. I come accross the following post from 2007. It seems that it's not possible to log what the server sends as the lease time duration. People have modified the source to do that.

https://lists.isc.org/pipermail/dhcp-users/2007-May/003671.html

On Mon, Oct 5, 2015 at 8:24 PM, Bob Harold <[hidden email]> wrote:

On Sun, Oct 4, 2015 at 3:47 PM, Glenn Satchell <[hidden email]> wrote:
Hi Alp

lease-time shows the remaining time in the lease, not the total time.

This is from the dhcp-eval man page:

     lease-time

       The duration of the current lease - that is,  the  differ-
       ence  between the current time and the time that the lease
       expires.

regards,
-glenn

On Sat, October 3, 2015 6:51 am, Denis Laventure wrote:
> The client will renew the lease at half the max-lease-time. So seeing 150
> sec for a 300 sec lease seems normal.
>
> Hi,
>
> I have an easy question I believe, I want to log DHCP lease durations
> given to clients, I tried the following, however it appears most of the
> time, logs are showing half of the lease duration.
>
> log(info, concat( "IP: ", binary-to-ascii(10, 8, ".", leased-address), " ;
> ", "leasetime:", binary-to-ascii(10,32,"",encode-int(lease-time,32)) ));
>
> I have set the following lease time values for a pool:
>
> subnet 172.16.2.0 netmask 255.255.255.0 {
>   option routers 172.16.2.1;
>   pool {
>     failover peer "failover-partner";
>     default-lease-time 300;
>     min-lease-time 300;
>     max-lease-time 300;
>     range
172.16https://www.dibbssm.net/GroupFiles/Group167/Documents/Cubs/E1_Cub_Fun_In_the_Snow.pdf.2.10
172.16.2.250;
>   }
> }
>
> And this configuration produces an output like this:
>
> Oct  2 14:34:44 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:37:10 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
> Oct  2 14:37:13 mercan dhcpd: IP: 172.16.2.127 ; leasetime:297
> Oct  2 14:39:37 mercan dhcpd: IP: 172.16.2.127 ; leasetime:156
> Oct  2 14:42:03 mercan dhcpd: IP: 172.16.2.127 ; leasetime:154
> Oct  2 14:44:28 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:46:53 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:49:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:155
> Oct  2 14:49:54 mercan dhcpd: IP: 172.16.2.127 ; leasetime:264
> Oct  2 14:50:47 mercan dhcpd: IP: 172.16.2.127 ; leasetime:247
> Oct  2 14:51:18 mercan dhcpd: IP: 172.16.2.127 ; leasetime:269
>
> How can log the precise lease durations, would be great if anyone has any
> suggestions?
>
> Thanks in advance.
> Alp

Reading the man pages, try replacing:
     lease-time
with:
      config-option dhcp-lease-time

But do some packet traces to be sure that it truly gives the lease time in the first ack packet, which might be the mclt instead of the normal lease time if failover is used.

I would like to try it myself sometime when I get a chance.

-- 
Bob Harold


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users