Freeing leases with OMSHELL
Christof Chen
christof at chen.de
Fri Nov 3 20:26:48 UTC 2006
> set the state to one (1=free), and then
> update the lease. This causes the lease to be updated in the dhcpd.leases
> file, showing that the state is indeed free. However, if the 11th client
> again attempts to get a lease, the server still complains that there are
> "no free leases".
The server still waits until the "ends" time before it hands out a new lease.
You have to reset the "ends" time as well. 3.0.4 does not allow this out of
the box, but you may try this patch (no guarantees, of course):
Modified: trunk/current/server/omapi.c
===================================================================
--- trunk/current/server/omapi.c 2006-07-27 11:28:37 UTC (rev 28)
+++ trunk/current/server/omapi.c 2006-10-27 15:40:36 UTC (rev 29)
@@ -261,7 +261,20 @@
} else if (!omapi_ds_strcmp (name, "starts")) {
return ISC_R_NOPERM;
} else if (!omapi_ds_strcmp (name, "ends")) {
- return ISC_R_NOPERM;
+ unsigned long bar,ole;
+ status = omapi_get_int_value (&bar, value);
+ if (status != ISC_R_SUCCESS)
+ return status;
+ ole = lease -> ends;
+ lease -> ends = bar; /* CC test */
+ if (supersede_lease (lease, 0, 1, 1, 1)) {
+ log_info ("lease %s end changed from %lu to %lu",
+ piaddr(lease->ip_addr), ole, bar);
+ return ISC_R_SUCCESS;
+ }
+ log_info ("lease %s end changed from %lu to %lu failed",
+ piaddr(lease->ip_addr), ole, bar);
+ return ISC_R_IOERROR;
} else if (!omapi_ds_strcmp (name, "billing-class")) {
return ISC_R_UNCHANGED; /* XXX carefully allow change. */
} else if (!omapi_ds_strcmp (name, "hardware-address")) {
This makes "ends" writable for a lease via OMAPI. I have not tried anything
beyond ends = starts, but this made the lease immediately available for a new
client.
--
Christof Chen
More information about the dhcp-users
mailing list