Logging host-name and hardware
Ray Phillips
r.phillips at jkmrc.com
Thu Jan 8 07:08:46 UTC 2009
Wayne:
>I am working on logging option82 information for requests. I would
>like to just have one line that gives the option82 information,
>lease time, IP address, hardware address, and host-name if the
>client has it set. Currently I am using.
>
>if exists agent.remote-id
> {
> log ( info, concat( "lease,", binary-to-ascii (10, 8, ".",
>leased-address),",",
> "agent,",option agent.remote-id,",",
> "time,",binary-to-ascii(10,32,"",encode-int (lease-time,32)),",",
> "hardware,",binary-to-ascii(16,8,":",substring(hardware,1,7))
> ) );
>
>This gives me
>lease,192.168.11.250,agent,0003,time,600,hardware,0:1e:a:db:58:4f
>
>I would like to see the hardware address get formatted with
>XX:XX:XX:XX:XX:XX currently if the hex value starts with 0 if gets
>dropped.
This piece of configuration-file code (courtesy of Glenn [1]) inserts
the leading 0 when required:
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)
)
>Also I can't figure out how to extract the host-name.
I'm not too confident about this but I use this code to assign DNS
names to hosts which don't provide a name to the dhcp server:
option server.ddns-hostname = pick-first-value (
option fqdn.hostname,
option host-name,
concat (
"nn-",
# 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)
)
);
so perhaps you need option fqdn.hostname
Ray
[1] http://marc.theaimsgroup.com/?l=dhcp-server&m=105689607527110&w=2
More information about the dhcp-users
mailing list