SV: running script at the time of address lease
Jon Otterholm
jon.otterholm at ide.resurscentrum.se
Mon Feb 14 11:19:38 UTC 2011
The short answer is no, but there are ways to solve this.
I use the exec function in syslog to execute scripts upon lease/expire. You can configure dhcpd to do logging which includes the information you need (IP, MAC ...). Here is an example:
Dhcpd.conf
______
log-facility local6;
on commit { log(info, concat("commit", " ", binary-to-ascii(10, 8, ".", leased-address), " ", concat (
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 1, 1))),2),":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 2, 1))),2),":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 3, 1))),2),":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 4, 1))),2),":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 5, 1))),2),":",
suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 6, 1))),2)
), " ", "'", (option agent.circuit-id), "'"));
}
on expiry { log(info, concat("expiry", " ", binary-to-ascii(10, 8, ".", leased-address)));
}
on release { log(info, concat("expiry", " ", binary-to-ascii(10, 8, ".", leased-address)));
}
___________
Syslog.conf:
___
local6.debug | exec /usr/bin/awk '$6=="commit"{system("/usr/scripts/commit.sh" " " $7 " " $8 " " $9)}'
local6.debug | exec /usr/bin/awk '$6=="expiry"{system("/usr/scripts/release.sh" " " $7 " " $8 " " $9)}'
___
As you can see dhcpd will log to local6.debug, syslog pipes info to awk that filters info and sends it to a script together with necessary variables. In this example it sends IP, MAC and Option-82 to the script.
This runs on our FreeBSD-routers and it works really well. ~1000 customers/router and the lease-time is set to max 60min giving us about 2000 leases to handle per hour.
The advantage to this solution is the elimination of patches of dhcpd.
Hope this info helps, good luck.
//Jon
Från: dhcp-users-bounces+jon.otterholm=ide.resurscentrum.se at lists.isc.org [mailto:dhcp-users-bounces+jon.otterholm=ide.resurscentrum.se at lists.isc.org] För Tapan
Skickat: den 12 februari 2011 13:11
Till: dhcp-users at lists.isc.org
Ämne: running script at the time of address lease
Hi list,
Is there any way to run a script from dhcpd after an address is assigned to a host ?
Regards,
Tapan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20110214/2c3776cd/attachment.html>
More information about the dhcp-users
mailing list