[Kea-users] different lease times

Jason Keltz jas at yorku.ca
Thu Apr 4 16:33:20 UTC 2024


Hi Darren,

I tried your suggestion, but unfortunately, it didn't quite work.
I modified my kea configuration as you specified.  My default 
valid-lifetime is 4000.
In short-lease, I defined valid-lifetime to be 300 (exactly as yours is 
specified).
In the pool used by my test host, I added the client-class for 
short-lease as you specified.
I restarted kea dhcp server to ensure it re-read the configuration.
I checked for any existing lease from my test host "jastest", and there 
was none.
I booted...
The lease was registered, and was for 300 seconds...

[ { "arguments": { "leases": [ { "client-id": "01:ac:24:11:5f:be:b7", 
"cltt": 1712245568, "fqdn-fwd": false, "fqdn-rev": false, "hostname": 
"jastest", "hw-address": "ac:24:11:5f:be:b7", "ip-address": 
"130.63.XX.YY", "state": 0, "subnet-id": 6, "valid-lft": 300 } ] }, 
"result": 0, "text": "1 IPv4 lease(s) found." } ]

So good, so far, right?

I then assigned my test host an IP, cleared the DHCP lease for it, and 
booted... the host got the proper IP outside of the pool, but it ALSO 
had valid-lifetime 300 and not 4000!

Is this because:

        "client-classes": [
           {
             "name": "short-lease",
             "test": "member('KNOWN')",
             "valid-lifetime": 300
           }
         ],

... automatically adds "short-lease" to any member of KNOWN?

I just wish that ISC made it so that valid-lifetime could be configured 
in pool.

Jason.

On 4/4/24 05:34, Darren Ankney wrote:
> Hi Jason,
>
>   Something like this might work:
>
>         "client-classes": [
>            {
>              "name": "short-lease",
>              "test": "member('KNOWN')",
>              "valid-lifetime": 300
>            }
>          ],
> ...
>          "subnet4": [
>              {
>                  "subnet": "10.1.2.0/24",
>                  "id": 1,
>                  "option-data": [
>                      {
>                          "name": "routers",
>                          "data": "10.1.2.1"
>                      }
>                  ],
>                  "valid-lifetime": 300,
>                  "pools": [
>                      {
>                          "pool": "10.1.2.100-10.1.2.200",
>                          "client-class": [ "short-lease" ]
>                      }
>                  ]
>              }
>          ],
>
> On Wed, Apr 3, 2024 at 10:56 AM Jason Keltz <jas at yorku.ca> wrote:
>> Hi Darren,
>>
>> Yes - "lease-lifetime" was my error - I meant "valid-lifetime".
>> I understand that I cannot apply "valid-lifetime" to a pool (although I
>> feel like I should be able to).
>> I already define client-class as "KNOWN" in all my pools so that unknown
>> hosts can't get an IP, and I understand that I can't use a second
>> client-class of "short-lease" in each pool.
>> I looked in the Kea code where options are defined, and thought I would
>> be able to add:
>>
>>              {
>>                   "name": "dhcp-lease-time",
>>                   "data": "300"
>>               }
>>
>> ... to "option-data" section for each host, but this didn't work
>> either.  I see that in the Kea docs, all-options.json skips from code 49
>> to code 52, thereby skipping over code 51 which is lease time.
>>
>> I tried adding "code": 51, to the section to my option above, but it
>> didn't make any difference.
>>
>> I tried adding "valid-lifetime" to the "reservations" section to see if
>> that would work, but it would not.
>>
>> Therefore, I'm still not sure how to implement different lease times for
>> pools.
>>
>> Jason.
>>
>> On 4/3/24 06:35, Darren Ankney wrote:
>>> Hi Jason,
>>>
>>>
>>>> would it be valid syntax to also set lease-lifetime in the pool instead of using the class?
>>>>
>>>>    "pools": [
>>>>                       {
>>>>                           "pool": "10.1.2.100-10.1.2.200",
>>>>                            "lease-lifetime": "300"
>>>>                       }
>>>> ]
>>> I cannot find evidence of a parameter called "lease-lifetime" but
>>> "valid-lifetime" cannot be set inside a pools [] block.
>>>
>>>> I already assign the pools to "client-class": "KNOWN" - can I specify multiple classes? "client-class": "KNOWN", "short-lease"?
>>>> If I use a class to do this, is the "valid-lifetime": 300 inside the subnet definition necesary? It is repeated in both the subnet and the client-class short-lease.
>>> The "valid-lifetime" inside the subnet was a mistake.  That was a
>>> relic of some earlier testing.  You cannot specify multiple classes on
>>> a client-class line.  I don't know if you can have both client-class
>>> and client-classes as I've never tried.  "client-class" does not do
>>> the same thing that "client-classes" does.
>>>
>>> Thank you,
>>> Darren Ankney
>> --
>> ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.
>>
>> To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.
>>
>> Kea-users mailing list
>> Kea-users at lists.isc.org
>> https://lists.isc.org/mailman/listinfo/kea-users


-- 
Jason Keltz
Computer Development Manager
Department of Electrical Engineering and Computer Science
York University
Toronto, Ontario Canada
Tel: (416) 736-2100 x. 33570
Fax: (416) 736-5872



More information about the Kea-users mailing list