I love being able to have something triggered when a particular event occurs, and in the case of DHCP, I need to launch a program when a DHCP lease is granted. Since version 3.1.0, ISC DHCP can execute a program when a lease changes.
dhcpd.conf I have the following rules:
on keyword, which takes
expire, I declare the
set of statements I want executed when the event happens.
In the example above, when a lease is granted, the specified program is invoked with the four arguments. What this program does is immaterial, but I believe it should return as quickly as possible. Here’s what my dhcpd logs when a lease is granted:
If you are using the built-in mechanisms for DNS updates, you must not define events, as they are then used internally by dhcpd. (The manual page does, however, give hint at how to overcome that problem.)
You can use this mechanism, say, for updating a DNS server that has no built-in support for RFC 2136 DNS updates, and that is what Tom O’Connor does with DHCP and PowerDNS: his back-end program updates a MySQL database.