static clients: how log hostnames and create lease entries?

Frantisek Hanzlik franta at hanzlici.cz
Sat Dec 26 22:42:14 UTC 2009


Simon Hobson wrote:
> Frantisek Hanzlik wrote:
>
>> I there some way how, for host declarations with static addresses, do:
>>
>> 1) log client hostname (which client sent in DHCPREQUEST or DHCPDISCOVER
>> as option 12 ) ?
>>
>> 2) so that they appear in lease file ?
>
> I don't think so.
>
> However, if you converted to use reserved leases then the clients get
> 'real' leases which go through the normal lifecycle, appear in the
> leases file, and get DNS updates/deletes etc - the only difference from
> a normal lease being that a reserved lease will never be re-allocated to
> another client. I think you need version 4 for this functionality, and I
> don't know how well it's documented. I believe you need to manually add
> "reserved" as a keyword in an existing lease (or create a new skeleton
> lease with this) to uset he feature - and of course, that means stopping
> the server while you edit the leases file.


For now I have solved (but not sure when it's optimal) point 1) with
custom logging defined in global section as this:

----
on commit {
   if (static){set isst = "static";} else {set isst = "dynamic";}
   log (info, concat (
     "COMMIT IP,", binary-to-ascii (10,8,".",leased-address),
     ",MAC,", suffix (concat ("0", substring(binary-to-ascii (16, 8, ":", hardware), 2, 17)),17),
     ",hostname,", option host-name,
     ",host-decl-name,", pick-first-value(host-decl-name, "(none)"),
     ",dhcp-client-identifier,", pick-first-value(binary-to-ascii(16,8,"",option dhcp-client-identifier), "(none)"),
     ",vendor-class-identifier,", pick-first-value(option vendor-class-identifier, "(none)"),
     ",agent.remote,", pick-first-value(option agent.remote-id, "(none)"),
     ",agent.circuit,", pick-first-value(option agent.circuit-id, "(none)"),
     ",leasetime,", binary-to-ascii (10,32,"",encode-int (lease-time,32)),
     ",asstype,", isst
     )
   );
}
----
This produces (in addition to usual) log items as:

Dec 26 23:29:56 ns dhcpd: COMMIT IP,192.168.1.250,MAC,00:20:ed:72:fb:5f,hostname,q,host-decl-name,janusa,dhcp-client-identifier,1020ed72fb5f,vendor-class-identifier,MSFT 5.0,agent.remote,(none),agent.circuit,(none),leasetime,216000,asstype,static

which is quite sufficient for me.

This don't need any additional requirements, but it not solve point 2).
I have DHCP v4.0 or 4.1 servers (Fedora 10 - Fedora 12 machines), but
manually edit lease file seems little crazy for me.
"infinite-is-reserved On" dhcpd.conf statement isn't answer, because
as far as I understand man page, client itself must request infinite
lease time - which isn't realistic.
dhcpd.leases man page in addition to "reserved" mention also "bootp"
flag, but again without any details.

Then, I still not know, when there is any elegant way how put fixed
address hosts to dhcpd.leases file. I do not need any dyndns updates etc.

Any advice?

Thanks, Franta Hanzlík



More information about the dhcp-users mailing list