This is not a direct solution but it would seem you could make use of the on commit
facility within your DHCP configuration file. Here's an example from this articled titled: Execute a script when ISC DHCP hands out a new lease.
In the dhcpd.conf
file you can create actions on various events such as when a lease is given out.
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.2;
on commit {
set clip = binary-to-ascii(10, 8, ".", leased-address);
set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
execute("/usr/local/sbin/dhcpevent", "commit", clip, clhw, host-decl-name);
}
...
When the above script, dhcpevent
, runs it's passed 4 arguments.
execute_statement argv[0] = /usr/local/sbin/dhcpevent
execute_statement argv[1] = commit
execute_statement argv[2] = 192.168.1.40
execute_statement argv[3] = 11:aa:bb:cc:dd:ee
execute_statement argv[4] = d1.jp
clipw
& clhw
are variables where, in this example, portions of other meta data has been parsed and stored prior to running the script. These variables are then passed along with other items to the event script.
You could parley this approach into a script where you could keep track of the numbers of IPs that have been leased out or perhaps you could interrogate the actual lease status file that the DHCP server keeps track of this info (/var/lib/dhcpd/dhcpd.leases
), and then report if that files has a number of leases that exceeds your quota.
References