<span style="color: rgb(0, 0, 153);">Many thanks for your answers..</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">I am using fedora 14 with dhcpd 4.1.1-P1.</span><br><br>On Mon, Feb 14, 2011 at 9:55 PM, Glenn Satchell <<a href="mailto:glenn.satchell@uniq.com.au">glenn.satchell@uniq.com.au</a>> wrote:<br>
> Hi Jon<br>><br>> execute() was implemented in 3.1.0, so if you tried 3.0.x then it wouldn't<br>> recognise the command.<br>><br>> It is not possible to get the output of the command executed, but you can<br>
> test the exit status, so you might be able to do something with that. Syntax<br>> details are in the dhcp-eval man page.<br>><br>> I found this blog with some examples:<br>><br>> <a href="http://invalidmagic.wordpress.com/2010/03/27/magic-dhcp-stuff-isc-dynamic-host-configuration-protocol/">http://invalidmagic.wordpress.com/2010/03/27/magic-dhcp-stuff-isc-dynamic-host-configuration-protocol/</a><br>
<br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">I also tested with same conf described in the above link. But it didn't work.</span><br style="color: rgb(0, 0, 153);"><span style="color: rgb(0, 0, 153);">Could anyone confirm, whether the above ex. is working or not or I missed something.</span><br>
<br>><br>> and this from the mailing list archives which is essentially the same thing<br>> posted 2 years earlier:<br>><br>> <a href="https://lists.isc.org/pipermail/dhcp-users/2008-September/007167.html">https://lists.isc.org/pipermail/dhcp-users/2008-September/007167.html</a><br>
><br>> regards,<br>> -glenn<br>><br>> On 02/15/11 01:16, Jon Otterholm wrote:<br>>><br>>> OK, I tried to make execute work on 3.x without any luck. Seems like it<br>>> is fixed in 4.x. Is it possible to do conditional leases now? In other<br>
>> words: let an external script decide if the lease is OK or not (for<br>>> example based on option-82 info).<br>>><br>>> //Jon<br>>><br>>> *Från:*dhcp-users-bounces+jon.otterholm=<a href="http://ide.resurscentrum.se">ide.resurscentrum.se</a>@<a href="http://lists.isc.org">lists.isc.org</a><br>
>><br>>> [mailto:<a href="mailto:dhcp-users-bounces%2Bjon.otterholm">dhcp-users-bounces+jon.otterholm</a>=<a href="http://ide.resurscentrum.se">ide.resurscentrum.se</a>@<a href="http://lists.isc.org">lists.isc.org</a>]<br>
>> *För *Denis Laventure<br>>> *Skickat:* den 14 februari 2011 14:53<br>>> *Till:* Users of ISC DHCP<br>>> *Ämne:* RE: running script at the time of address lease<br>>><br>>> What about :<br>
>><br>>> on commit { execute("command") } ?<br>>><br>>> from dhcp-eval man page :<br>>><br>>> *execute (/command-path [, data-expr1, ... data-exprN]);/*<br>>><br>>> The *execute* statement runs an external command. The first argument is<br>
>> a string literal containing the name or path of the command to run. The<br>>> other arguments, if present, are either string literals or data-<br>>> expressions which evaluate to text strings, to be passed as command-line<br>
>> arguments to the command.<br>>><br>>> *execute*is synchronous; the program will block until the external<br>>> command being run has finished. Please note that lengthy program<br>>> execution (for example, in an "on commit" in dhcpd.conf) may result in<br>
>> bad performance and timeouts. Only external applications with very short<br>>> execution times are suitable for use.<br>>><br>>> Passing user-supplied data to an external application might be<br>
>> dangerous. Make sure the external application checks input buffers for<br>>> validity. Non-printable ASCII characters will be converted into<br>>> dhcpd.conf language octal escapes ("777"), make sure your external<br>
>> command handles them as such.<br>>><br>>> It is possible to use the execute statement in any context, not only on<br>>> events. If you put it in a regular scope in the configuration file you<br>
>> will execute that command every time a scope is evaluated.<br>>><br>>> I’m running ISC DHCPD v. 4.2.0<br>>><br>>> Denis<br>>><br>>> *De :*dhcp-users-bounces+denis_laventure=<a href="http://uqac.ca">uqac.ca</a>@<a href="http://lists.isc.org">lists.isc.org</a><br>
>> [mailto:<a href="mailto:dhcp-users-bounces%2Bdenis_laventure">dhcp-users-bounces+denis_laventure</a>=<a href="http://uqac.ca">uqac.ca</a>@<a href="http://lists.isc.org">lists.isc.org</a>] *De la<br>>> part de* Jon Otterholm<br>
>> *Envoyé :* 14 février 2011 06:20<br>>> *À :* Users of ISC DHCP<br>>> *Objet :* SV: running script at the time of address lease<br>>><br>>> The short answer is no, but there are ways to solve this.<br>
>><br>>> I use the exec function in syslog to execute scripts upon lease/expire.<br>>> You can configure dhcpd to do logging which includes the information you<br>>> need (IP, MAC …). Here is an example:<br>
>><br>>> Dhcpd.conf<br>>><br>>> ______<br>>><br>>> log-facility local6;<br>>><br>>> on commit { log(info, concat("commit", " ", binary-to-ascii(10, 8, ".",<br>
>> leased-address), " ", concat (<br>>><br>>> suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 1,<br>>> 1))),2),":",<br>>><br>>> suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 2,<br>
>> 1))),2),":",<br>>><br>>> suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 3,<br>>> 1))),2),":",<br>>><br>>> suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 4,<br>
>> 1))),2),":",<br>>><br>>> suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 5,<br>>> 1))),2),":",<br>>><br>>> suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware, 6,<br>
>> 1))),2)<br>>><br>>> ), " ", "'", (option agent.circuit-id), "'"));<br>>><br>>> }<br>>><br>>> on expiry { log(info, concat("expiry", " ", binary-to-ascii(10, 8, ".",<br>
>> leased-address)));<br>>><br>>> }<br>>><br>>> on release { log(info, concat("expiry", " ", binary-to-ascii(10, 8, ".",<br>>> leased-address)));<br>>><br>
>> }<br>>><br>>> ___________<br>>><br>>> Syslog.conf:<br>>><br>>> ___<br>>><br>>> local6.debug | exec /usr/bin/awk<br>>> '$6=="commit"{system("/usr/scripts/commit.sh" " " $7 " " $8 " " $9)}'<br>
>><br>>> local6.debug | exec /usr/bin/awk<br>>> '$6=="expiry"{system("/usr/scripts/release.sh" " " $7 " " $8 " " $9)}'<br>>><br>>> ___<br>
>><br><font color="#000099">Its quite interesting & </font><span style="color: rgb(0, 0, 153);">also a generic way to handle many things</span>.<br><span style="color: rgb(0, 0, 153);">I tried with rsyslogd ,but ... hard luck here also </span><br>
>> As you can see dhcpd will log to local6.debug, syslog pipes info to awk<br>>> that filters info and sends it to a script together with necessary<br>>> variables. In this example it sends IP, MAC and Option-82 to the script.<br>
>><br>>> This runs on our FreeBSD-routers and it works really well. ~1000<br>>> customers/router and the lease-time is set to max 60min giving us about<br>>> 2000 leases to handle per hour.<br>>><br>
>> The advantage to this solution is the elimination of patches of dhcpd.<br>>><br>>> Hope this info helps, good luck.<br>>><br>>> //Jon<br>>><br>>> *Från:*dhcp-users-bounces+jon.otterholm=<a href="http://ide.resurscentrum.se">ide.resurscentrum.se</a>@<a href="http://lists.isc.org">lists.isc.org</a><br>
>><br>>> [mailto:<a href="mailto:dhcp-users-bounces%2Bjon.otterholm">dhcp-users-bounces+jon.otterholm</a>=<a href="http://ide.resurscentrum.se">ide.resurscentrum.se</a>@<a href="http://lists.isc.org">lists.isc.org</a>]<br>
>> *För *Tapan<br>>> *Skickat:* den 12 februari 2011 13:11<br>>> *Till:* <a href="mailto:dhcp-users@lists.isc.org">dhcp-users@lists.isc.org</a><br>>> *Ämne:* running script at the time of address lease<br>
>><br>>> Hi list,<br>>> Is there any way to run a script from dhcpd after an address is assigned<br>>> to a host ?<br>>><br>>> Regards,<br>>> Tapan<br>>><br>> _______________________________________________<br>
> dhcp-users mailing list<br>> <a href="mailto:dhcp-users@lists.isc.org">dhcp-users@lists.isc.org</a><br>> <a href="https://lists.isc.org/mailman/listinfo/dhcp-users">https://lists.isc.org/mailman/listinfo/dhcp-users</a><br>
><br><br>