Debian – DHCP on-the-fly block assignment

debiandhcpisc-dhcp

We have a large number of clients who connect to our DHCP machine. We want to assign some of them to a different IP block, which is routed with lower priority. Every DHCP lease renewal, we'd like to check a database and decide which IP block we'd like to assign a customer to.

Is there a way to have a DHCP server execute a script, look in a database, or execute some dynamic code when deciding which address to assign in which pool? Each client is uniquely identified by option82, aka "DHCP Relay Agent Information Option".

Best Answer

Ideally, you'd modify dhcpd to support address assignment based on Option82, equivalent to the "hardware" lines in host objects. I've done it with the OpenBSD dhcpd when I worked at an ISP, which has a simpler internal structure to isc-dhcpd.

If you're not in a position to do that, then look at omapi(3) and omshell(1); you'd use OMAPI to dynamically create "class" and "pool" objects, to implement Zypher's suggestion. I just checked dhcpd.h and the class struct has an OMAPI_OBJECT_PREAMBLE, so this should be possible. Beware that the documentation on OMAPI can be a little ... skimpy.

Related Topic