Howto clear a DHCPv6 lease?

adm@rtr2:~$ show dhcpv6 server leases
IPv6 address        MAC address        State    Last communication         Lease expiration           Remaining    Pool    Hostname    Type    DUID
------------------  -----------------  -------  -------------------------  -------------------------  -----------  ------  ----------  ------  -----------------------------------------------------
2001:0db8::::/64  00:15:5d:31:00:25  active   2026-05-19 13:22:48+00:00  2026-05-19 15:22:48+00:00  1:35:03      VLAN62  -           IA_PD   00:04:b8:ec:53:72:7e:32:4e:5c:b0:db:02:fe:58:7b:c6:46
xantion-adm@rtr2:~$ clear dhcpv6-server lease
Possible completions:
  <text>                DHCPv6 server lease


adm@rtr2:~$ clear dhcpv6-server lease 2001:0db8::::/64
Lease not found on DHCPv6 server
adm@rtr2:~$ clear dhcpv6-server lease 00:15:5d:31:00:25
Lease not found on DHCPv6 server
adm@rtr2:~$ clear dhcpv6-server lease 00:04:b8:ec:53:72:7e:32:4e:5c:b0:db:02:fe:58:7b:c6:46
Lease not found on DHCPv6 server

so what do i have to fill in as <text>?

VyOS 1.5.0

The underlying command is

${vyos_op_scripts_dir}/dhcp.py clear_dhcp_server_lease --family inet6 --address $4

which suggests it should be the address without the prefix.

What I find odd is that the show command doesn’t show an address, “2001:0db8::::/64” is a subnet?

It is a subnet. DHCP Server — VyOS 1.5.x (circinus) LTS

You missed my point.

In the example there, the following pool is defined:
set service dhcpv6-server shared-network-name ‘PD-NET’ subnet 2001:db8::/64 range 1 start 2001:db8::100
set service dhcpv6-server shared-network-name ‘PD-NET’ subnet 2001:db8::/64 range 1 stop 2001:db8::199

Which means DHCP v6 will assign an address (not a subnet) between 2001:db8::100and 2001:db8::199.

So I expect “show dhcpv6 server leases” to show the address issued (like the table header says), not a subnet with a prefix.

See the whole example. Not the two lines you think proof a point.

In the example there is the prefix-delegation. Which means DHCPdv6 is handing out subnets.

See ⚓ T3771 DHCPv6 server prefix delegation - dynamically add route to delegated prefix via requesting router

Kee.

I’ve looked into the python code, it calls the kea API function lease6-get-all, which returns something like

        "leases": [
            {
                "cltt": 12345678,
                "duid": "42:42:42:42:42:42:42:42",
                "fqdn-fwd": false,
                "fqdn-rev": true,
                "hostname": "myhost.example.com.",
                "hw-address": "08:08:08:08:08:08",
                "iaid": 1,
                "ip-address": "2001:db8:2::1",
                "preferred-lft": 500,
                "state": 0,
                "subnet-id": 44,
                "type": "IA_NA",
                "valid-lft": 3600
            },
            {
                "cltt": 12345678,
                "duid": "21:21:21:21:21:21:21:21",
                "fqdn-fwd": false,
                "fqdn-rev": true,
                "hostname": "",
                "iaid": 1,
                "ip-address": "2001:db8:0:0:2::",
                "preferred-lft": 500,
                "prefix-len": 80,
                "state": 0,
                "subnet-id": 44,
                "type": "IA_PD",
                "valid-lft": 3600
            }
        ]

It then compares the value of the “ip-address” element with whatever you typed.

As you can see in the API result, the ip address for a range is returned without prefix, which suggests the correct command is
clear dhcpv6-server lease 2001:0db8::::

Thanks for lookin ito this.

adm@rtr2:~$ show dhcpv6 server leases
IPv6 address          MAC address        State    Last communication         Lease expiration           Remaining    Pool    Hostname    Type    DUID




2001:0db8::/64  00:15:5d:31:00:25  active   2026-05-21 08:14:40+00:00  2026-05-21 10:14:40+00:00  1:54:09      VLAN62        IA_PD   00:04:b8:ec:53:72:7e:32:4e:5c:b0:db:02:fe:58:7b:c6:46
adm@rtr2:~$ clear dhc
dhcp-server    dhcpv6-server
adm@rtr2:~$ clear dhcpv6 lease 2001:0db8::
Failed to clear lease for “2001:0db8::”

Anything i can do to het more logs/info?

At least we’ve now found the correct value for the clear command.

The code now calls the lease-del() API function. The kea docs say:

The IPv6 address leases are deleted the same way, but using lease6-del. The IPv6 prefix leases are also deleted using lease6-del, but with some extra steps. The prefix should be referenced by its address and prefix length should be ignored. For example, to delete 2001:db8:1::/48, the following command can be used. The subnet-id parameter is optional.
{
“command”: “lease6-del”,
“arguments”: {
“ip-address”: “2001:db8:1::”,
“type”: “IA_PD”,
“subnet-id”: 1
}
}

If I look in the code, it only passes the “ip-address” field, so the check for a PD address, and if detected adding the additional arguments to the API call, is missing.

I suggest you report this a s bug in kea.py.

You might try working around it yourself, and see if this works, find kea.py on your router, find “def kea_delete_lease”, and replace it with:

def kea_delete_lease(inet, vrf_name, ip_address):
    args = {'ip-address': ip_address}
    if ip_address.endswith(':'):
        args['type'] = 'IA_PD'

    result = _ctrl_socket_command(inet, vrf_name, f'lease{inet}-del', args)

    if result and 'result' in result:
        return result['result'] == 0

    return False

assuming that addresses ending with a colon are actually subnets.