Page MenuHomeVyOS Platform

Add clear dhcp server lease function
Open, LowPublicFEATURE REQUEST

Description

Dear, Developers
I need dhcp lease clear feature.

After enable this

set service dhcp-server hostfile-update

I can find hostname of linux servers with hosts file. But when i try to rename the hostname. Where i can clean dhcp lease immediatly?
I found that edgeos has the command clear dhcp lease ip 172.16.3.20 to force delete the lease. Can we implement in vyos ? This is immport for me.

Clear DHCP Lease

my vyos version:

[email protected]# run show version
Version:          VyOS 1.2.1
Built by:         Sentrium S.L.
Built on:         Sun 14 Apr 2019 12:13 UTC
Build ID:         4ccd819a-db31-452e-b34b-a0b24af4e984

Architecture:     x86_64
Boot via:         installed image
System type:      KVM guest

Hardware vendor:  Bochs
Hardware model:   Bochs
Hardware S/N:     Unknown
Hardware UUID:    Unknown

Copyright:        VyOS maintainers and contributors
[edit]

Your Sincerely!
Steve Dong

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close

Event Timeline

syncer triaged this task as Low priority.
syncer edited projects, added VyOS 1.3 Equuleus; removed VyOS 1.2 Crux.

Sadly, two years later, OMAPI is still unsuitable for this purpose.

There is NO way to delete a lease:

[email protected]:~$ omshell
> key defomapi ...
> connect
>new "lease"
> set ip-address = 10.91.19.70
obj: lease
ip-address = 0a:5b:13:46

>remove
can't destroy object: not implemented

Some people suggest setting the state of an existing lease to free (code 1), e.g. the author of omcmd (which, by the way, no longer compiles). However, that doesn't work either.

Instead, it creates a duplicate least in the "free" state, but the original lease with the "active" state persits, so the action has no effect.

Last tested on 4.4.1

PR https://github.com/vyos/vyos-1x/pull/1360

[email protected]:~$ show dhcp server leases 
IP address    Hardware address    State    Lease start          Lease expiration     Remaining    Pool    Hostname
------------  ------------------  -------  -------------------  -------------------  -----------  ------  ----------
100.64.0.18   96:b2:9e:44:66:f7   active   2022/06/16 08:20:26  2022/06/17 08:20:26  23:59:51     Lan201  r1
100.64.0.19   6e:20:b8:d7:fe:94   active   2022/06/16 08:20:23  2022/06/17 08:20:23  23:59:48     Lan201  r1
100.64.0.20   d2:ba:67:15:19:f1   active   2022/06/16 07:40:19  2022/06/17 07:40:19  23:19:44     Lan201  r1
100.64.0.21   1a:54:70:d9:ef:c8   active   2022/06/16 02:55:05  2022/06/17 02:55:05  18:34:30     Lan201  r1
100.64.0.22   4a:02:50:3c:41:a7   active   2022/06/16 03:47:06  2022/06/17 03:47:06  19:26:31     Lan201  r1
[email protected]:~$ 
[email protected]:~$ 
[email protected]:~$ clear dhcp-server lease 100.64.0.18
This will restart DHCP server.
Continue? [y/N] y
[email protected]:~$ 
[email protected]:~$ 
[email protected]:~$ show dhcp server leases 
IP address    Hardware address    State    Lease start          Lease expiration     Remaining    Pool    Hostname
------------  ------------------  -------  -------------------  -------------------  -----------  ------  ----------
100.64.0.19   6e:20:b8:d7:fe:94   active   2022/06/16 08:20:23  2022/06/17 08:20:23  23:59:41     Lan201  r1
100.64.0.20   d2:ba:67:15:19:f1   active   2022/06/16 07:40:19  2022/06/17 07:40:19  23:19:37     Lan201  r1
100.64.0.21   1a:54:70:d9:ef:c8   active   2022/06/16 02:55:05  2022/06/17 02:55:05  18:34:23     Lan201  r1
100.64.0.22   4a:02:50:3c:41:a7   active   2022/06/16 03:47:06  2022/06/17 03:47:06  19:26:24     Lan201  r1
[email protected]:~$ 
[email protected]:~$