>Необходимо запускать некий скрипт при каждой раздаче IP адреса юзерам, и при
>этом знать все параметны, которые dhcp сервер им передает(ну хотяб МАС
>и IP).
>Это вообще можно как-нибудь сделать?
>Погуглил, ни чего не нарыл :(
>может быть как можно в реалтайме отслеживать изменение dhcpd.leasses ?
>
>p.s.
>FreeBSD 6.4
>DHCPd 4.1.0 Вот скрипт, который генерит html страницу, добавь в крон, и запусти апач. Будет тебе счастье.
#
# dhcp.awk
#
# awk -f dhcp.awk < /var/db/dhcpd.leases
#
# dhcpd leases to html done in AWK
# Copyright (C) 2005 Juan J. Martнnez <reidrac*at*blackshell.usebox.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
BEGIN {
printf("<html>\n<head>\n<title>DHCP leases</title>\
<style type=\"text/css\">\
table { border: 1px solid #eee; width: 100%% }\
.header { background-color: #aaa; font-weight: bold }\
.data0 { background-color: #fff }\
.data1 { background-color: #eee }\
</style>\
</head>\n<body>\n");
printf("<h1>DHCP leases</h2>\n");
lease=0;
header=0;
fields=0;
data=0;
}
lease==0 && /lease\ [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\ {/ {
lease=1;
if (header==0)
{
printf("<table class=\"table\">\
<tr class=\"header\">\
<td>IP</td>\n<td>Start</td>\n<td>End</td>\
<td>MAC Addr.</td>\n<td>Hostname</td>\n</tr>\n");
header=1;
}
if (data==0)
{
printf("<tr class=\"data0\">\n");
data=1;
}
else
{
printf("<tr class=\"data1\">\n");
data=0;
}
printf("<td>%s</td>\n", $2);
fields++;
}
lease==1 && /starts\ [^;]*;/ {
sub(";", "", $4);
printf("<td>%s %s</td>\n", $3, $4);
fields++;
}
lease==1 && /ends\ [^;]*;/ {
sub(";", "", $4);
printf("<td>%s %s</td>\n", $3, $4);
fields++;
}
lease==1 && /hardware\ ethernet\ [^;]*;/ {
sub(";", "", $3);
printf("<td>%s</td>\n", $3);
fields++;
}
lease==1 && /client-hostname\ [^;]*;/ {
gsub(";", "", $2);
printf("<td>%s</td>\n", $2);
fields++;
}
lease==1 && /}/ {
lease=0;
for(i=0;i<5-fields;i++)
printf("<td> </td>\n");
fields=0;
printf("</tr>\n");
}
END {
if (header==0)
{
printf("<p>There are no leases</p>\n");
}
else
{
printf("</table>\n");
}
printf("</body>\n</html>\n");
}