OPNsense Forum

English Forums => 25.1, 25.4 Production Series => Topic started by: 9axqe on July 15, 2025, 06:40:18 PM

Title: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: 9axqe on July 15, 2025, 06:40:18 PM
ISC had a button that allowed this conversion, this does not seem to exist in Kea, at least not for DHCPv6.

Attempting to create a static reservation fails, because the DUID already exists (as a dynamic lease).
Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: Monviech (Cedrik) on July 15, 2025, 06:58:16 PM
dnsmasq has that button since it supports this kind of conversion transparently.
Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: IsaacFL on July 16, 2025, 01:05:57 AM
He asked about KEA, not dnsmasq.  I am also curious when this will be added to KEA dhcpv6?

I also find that the DUID column hides most the text field, so I cant manually copy to create my own static entry. What I have had to do is use my external logging to find the DUIDs.

Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: Monviech (Cedrik) on July 16, 2025, 07:04:11 AM
In upcoming 25.7 the grids have been reworked to be able to move columns and resize them, which will improve text in them not fully showing.

Im curious what exactly fails when creating a reservation with the same DUID as an existing lease, does KEA crash or something? Or logs it that its ignored?
Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: 9axqe on July 16, 2025, 07:40:08 AM
When the DUID appears truncated, you can still copy the entire DUID. Just double click the DUID to the entire cell becomes highlighted/selected and press ctrl-C. It will copy the entire DUID, including the part which is hidden.

I believe this is called a CSS text overflow ellipsis, this is not specific to the opnsense web interface.
Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: 9axqe on July 16, 2025, 07:42:31 AM
Quote from: Monviech (Cedrik) on July 16, 2025, 07:04:11 AMIm curious what exactly fails when creating a reservation with the same DUID as an existing lease, does KEA crash or something? Or logs it that its ignored?

Upon clicking "save", the DUID field becomes circled with red, and a red text appears on the right of the DUID field, stating: "Duplicate entry exists"
Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: 9axqe on July 16, 2025, 07:49:22 AM
This is the feature request for DHCPv4 as far as I can tell, although it does not explicitly say IPv4, it mentions MAC:

https://github.com/opnsense/core/issues/7950
Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: Monviech (Cedrik) on July 16, 2025, 07:58:15 AM
The DUID has a unique per subnet constraint, it does not reference any existing leases data in the current kea leases database to constrain its usage.

https://github.com/opnsense/core/blob/7d0a448157dd7fe115200fe0701669e43d9e6352/src/opnsense/mvc/app/models/OPNsense/Kea/KeaDhcpv6.xml#L109-L122

In my test this only triggers if you create two entries with the same DUID or the same IP address in the same subnet.
Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: 9axqe on July 16, 2025, 08:01:31 AM
Is there a way to delete a lease? I could manually delete it, and add the reservation.

The volume of such occurrences in my case is low, hence that would be manageable for now.
Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: Monviech (Cedrik) on July 16, 2025, 08:19:16 AM
The code just checks for existing reservations in your configuration (config.xml). It does not check the leases database of kea.

Are you sure you don't have an existing reservation already that has the same DUID?
Title: Re: Convert dynamic Kea DHCPv6 leases into static DHCPv6 reservations
Post by: 9axqe on July 16, 2025, 08:36:03 AM
Ah, thanks, now I see what the issue is. Interesting.

The reservation is for a Raspberry Pi 4 which is connected both over Wi-Fi and LAN. It is the same DUID on both interfaces, but different IPv6 are assigned for each interface, presumably due to the IAID.

Now the interesting part is that ISC DHCPv6 erroneously assigns the **same** IPv6 on both interfaces, leading to IP conflicts (Raspberry Pi not happy). Kea on the other hand correctly tells apart the two interfaces are provides it two different IPv6.

The problem of Kea is of course for creating reservations in such a scenario, since it only checks for DUID and not IAID.