static clients: how log hostnames and create lease entries?

Frantisek Hanzlik franta at hanzlici.cz
Sun Dec 27 01:08:10 UTC 2009


Glenn Satchell wrote:
> Hi Frantisek
>
> One other possibility is to offer a *really* long regular lease, like 1
> or 2 years. It will effectively be the same as a static lease, but will
> be a dynamic lease and go through all the dynamic lease things, like
> dhcpd.leases, but without worrying about the hassle of reserved leases.
>
> group {
> 	# 1 year in seconds
> 	min lease-time 31536000;
> 	host "host1" { hardware ethernet x:x:x:x:x:x ; }
> 	host "host2" { hardware ethernet y:y:y:y:y:y ; }
> 	...
> }
>
> or you could do a similar thing with a class and sub-class, note the
> leading 1 which means media type ethernet.
>
> class "really-long" {
> 	match pick-first-value (option dhcp-client-identifier, hardware);
> 	# 1 year in seconds
> 	min lease-time 31536000;
> }
> subclass "really-long" 1:x:x:x:x:x:x;
> subclass "really-long" 1:y:y:y:y:y:y;
>
> regards,
> -glenn
>
>> Date: Sat, 26 Dec 2009 23:42:14 +0100
>> From: Frantisek Hanzlik<franta at hanzlici.cz>
>>
>> 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-cli
> ent-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

Hello Glenn,

Your concept would be fine, but how then is possible assign fixed IP
address to these hosts? When I use "fixed-address" statement, then these
hosts not appear in dhcpd.leases, as there are only dynamically assigned
ones, I'm right? Or is other way how tight assign for given hardware
ethernet address given IP address?

Regards,
Franta Hanzlík



More information about the dhcp-users mailing list