static clients: how log hostnames and create lease entries?

Frantisek Hanzlik franta at hanzlici.cz
Sun Dec 27 12:18:18 UTC 2009


Glenn Satchell wrote:
>
>> Date: Sun, 27 Dec 2009 03:00:26 +0100
>> From: Frantisek Hanzlik<franta at hanzlici.cz>
>>
>> Glenn Satchell wrote:
>>>
>>>> Date: Sun, 27 Dec 2009 02:08:10 +0100
>>>> From: Frantisek Hanzlik<franta at hanzlici.cz>
>>>>
>>>> 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
>>>
>>> Ah, yes, I see what you mean. You won't know in advance what the IP
>>> address will be, but once the PC is given a dynamic address then it
>>> won't change. If you use a 1 year lease, then at around 6 months the PC
>>> will try and renew for another 1 year.
>>>
>>> If you need to lock it down then you could create separate pool(s) with
>>> a specific range of IP addresses, eg something like this:
>>>
>>> subnet 192.168.1.0 netmask 255.255.255.0 {
>>> 	...
>>> 	pool {
>>> 		deny members of "really-long";
>>> 		range ...
>>> 		...
>>> 	}
>>> 	pool {
>>> 		allow members of "really-long";
>>> 		# treat this range like fixed addresses
>>> 		range 192.168.1.20 192.168.1.30;
>>> 	}
>>> }
>>>
>>> regards,
>>> -glenn
>>
>> Ah so, I understand this idea, and its seems reasonable. I use Your
>> reccomendations. Many thanks!
>>
>> But anyway I cannot get on, why, in powerfull ISC dhcpd with tons of its
>> options, is so hard solve this problem. I don't well understand all of
>> aspects about it, but I like idea of dhcpd.leases database with all
>> controlled hosts.
>
> I think it was an optimisation that was done in a very early version,
> maybe 2.0? The idea was that a host with a fixed-address didn't need to
> store or process the lease state information as the server would hand
> out the same fixed IP address for every request from that client.

At that time, when project was started, it is quite reasonable. But this
was maybe ten+ years ago (I think I was then using it in RedHat 5.x or so).
(For curious, I just found dhcpd.leases from my one old configuration,
from 1997 year, and this contain "dynamic-bootp" flag! Actual "bootp"
and "reserved" flags are probably successors of its)
But peoples are more and more luxurious :) and when this dhcpd.leases
facility allow better client recapitulation, why not extend it with
informations which are usefull for network maintenance?


> I think reserved leases are meant to provide the facility you need, but
> as yet there is no easy way to configure that in dhcpd.conf. It would
> be nice if you could set up a class, pool or host statement and specify
> 'reserved' in that context perhaps?

Yes, that would be nice.



More information about the dhcp-users mailing list