Need help with LEASEQUERY..
Pat Winn
ptwinn at cimtel.net
Fri Jun 18 14:03:59 UTC 2010
Jeffrey,
I figured out another way to obtain that information.
Consider this section from my dhcpd.conf:
set vendor-string = option vendor-class-identifier;
set vendor-enc-options = option vendor-encapsulated-options;
set myServerIP = "x.x.x.x";
# some pre-defined base mac addresses..
set BEC_MacID = "0004ed"; # BEC DSL Router
set CISCO_MacID = "00252e"; # Cisco DSL Router
set MOTO_MacID = "0023a2"; # Motorola Set Top Box
# Build a syslog string with all necessary info to log a session, then
send it to syslog..
# This is a tad ugly so please don't mess with anything here unless you
*really* know
# what you are doing! If any of the variables below are not present when
examined,
# dhcpd will behave badly (IMHO) and will NOT issue a syslog message. This
is why all
# the if statements below and attempts to ensure that each has some value
or another.
if((option dhcp-message-type = 3 or option dhcp-message-type = 5) and
exists agent.circuit-id) {
set myBaseMac = 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));
if(myBaseMac = BEC_MacID) {
set myDev = "BEC DSL Router";
} else if(myBaseMac = CISCO_MacID) {
set myDev = "Cisco DSL Router";
} else if(myBaseMac = MOTO_MacID) {
set myDev = "Motorolla STB";
} else {
set myDev = "unknown";
}
if(not exists vendor-class-identifier) {
set vend = concat(myDev, " (unknown)");
} else {
set vend = concat(myDev, " (", vendor-string, ")");
}
# build a syslog string and send it on to php_syslogd (or whatever
syslog agent is listening)
log(info, "-----------------------------------");
log(info, concat( "OPT82=1|MSGTYPE=",
binary-to-ascii (16, 8, "", option dhcp-message-type),
"|IP=",
binary-to-ascii (10, 8, ".",leased-address),"|MAC=",
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), "|VLAN=", cimVLAN,
"|LOC=", myLocation, "|SRV=", myServerIP, "|VEND=", vend,
"|CID=", (option agent.circuit-id)));
log(info, "-----------------------------------");
}
The resulting syslog message looks something like:
OPT82=1|MSGTYPE=3|IP=1.2.3.4|MAC=00:25:2e:03:98:20|VLAN=803|LOC=Some Town
- 555 Ring|SRV=2.3.4.5|VEND=Cisco DSL Router (uDHCP 0.9.6)|CID=555 Some
Town CO atm 10/1/13/2:0.35
So, while I more than agree that you can't expose those via leasequery
packets,
with a small amount of creativity in the dhcpd.conf, much can still be
done and/or
exposed to meet your needs.
--
Patrick T. Winn
Senior Systems Engineer
Cimarron Telephone Co.
(918) 865-3311 x280 - office
(918) 606-6602 - cell
While counting 0's and 1's, Jeffrey Hutzelman said:
> --On Friday, June 11, 2010 04:42:53 PM -0500 Pat Winn <ptwinn at cimtel.net>
> wrote:
>
>>
>> Also, is there any way to have it send back any user
>> options set in the dhcpd.conf which show up in the
>> lease file?
>>
>> For example, I have put into each of my network stanzas:
>>
>> set myLocation = "<some network location>"
>>
>> In the leases file, it gets added to the lease as:
>>
>> set myLocation = "<some network location>"
>>
>> Any way to ask for that information to be sent back
>> as part of the lease query response? I know the server
>> knows about it, but I see nothing in any docs about
>> how to try and retrieve it?
>
> No; that's internal server state and there is no way to query it via the
> DHCP protocol, short of configuring the server to expose it as an option
> value.
>
> -- Jeffrey T. Hutzelman (N3NHS) <jhutz+ at cmu.edu>
> Carnegie Mellon University - Pittsburgh, PA
>
>
More information about the dhcp-hackers
mailing list