Fixed dhcp host to automatically expire any lease

dhcp-serverdhcpdisc-dhcp

I have the following situation: Multiple offices with multiple firewall/dhcp servers.

Every time the IT team of some office plugs a new network printer i need to create a fixed-address entry, and delete the lease that this printer already got before this reservation happens. Sometimes i get warned that the printer is already online and this fixed ip is needed by other application(cups server).

Is there a way to "auto expire" a lease when you add a fixed-address? On the current situation i need to manually remove the lease or wait the 3 hours that is my configured max-lease-time.

Why i want this? To make more dinamic the creation of new fixed address hosts through ssh without the need of login on that server and erase a lease(or edit 2 files every time). dhcp-relay is not an option cause we have a circuit on our isp that will not support it.

Snip of some config files

ddns-update-style ad-hoc;
authoritative;
allow bootp;
deny declines;
deny duplicates;
option domain-name "xxx.net";
option domain-name-servers y.y.y.y, y.y.y.2;
option interface-mtu 1500;
option ntp-servers ntp.xxx.xxx.xxx;
default-lease-time 7200; # default lease 2 hours
max-lease-time 10800; # max lease 3 hours
one-lease-per-client true; # 1 lease per client

subnet 10.0.0.0 netmask 255.255.255.0 {
        range 10.0.0.100 10.0.0.200;
        option routers 10.0.0.254;
        option broadcast-address 10.0.0.255;
}


host printserver001 {
        hardware ethernet 00:24:81:XX:XX:XX;
        fixed-address 10.0.0.30;
}

Solution that i already tried: Create a class called printers, add all fixed address to that class and add a deny members of "printers" on that ip range/pool. It will not work and the printer will still get the lease until is expired.

Solution that i think might work: Zero the default-lease-time parameter. I just don´t know if the default behavior of all printers when they restart will be request the same lease or send a new DHCPREQUEST, and how isc-dhcp will manage this request.

Edit 1: Using omapi does not work either. I´m trying to delete a lease only knowing the mac address, and this is what i get when i try to delete it:

omshell << END_OF_INPUT
server localhost
port 7911
key omapi_key my_key_xxxxxxxxxxxxxxxxxx==
connect
new lease
set hardware-address = 00:e0:c5:4e:2d:a4
open
remove
END_OF_INPUT


> can't destroy object: not implemented
obj: lease
hardware-address = 00:e0:c5:4e:2d:a4
state = 00:00:00:02
ip-address = c0:a8:03:e6
dhcp-client-identifier = 01:00:e0:c5:4e:2d:a4
client-hostname = "xxxxx03"
subnet = 00:00:00:06
pool = 00:00:00:07
hardware-type = 00:00:00:01
ends = 53:72:14:ce
starts = 53:71:f8:ae
tstp = 00:00:00:00
tsfp = 00:00:00:00
atsfp = 00:00:00:00
cltt = 53:71:f8:ae
flags = 00
ddns-fwd-name = "xxxxx03.xxxxx.net"
ddns-rev-name = "xx.xx.xx.192.in-addr.arpa."

I´m using ISC-dhcp 3.1.1.

Any ideas?

Best Answer

You cannot delete the leases via OMAPI. However, you can forcibly RELEASE them, which will cause dhcpd to see it as no longer an active lease. Make the fixed-address entry, forcibly release the lease the printer obtained previously, and on the next DHCP negotiation the printer will be moved to the fixed address, including NAKing the renewal request and giving the client the new IP.