Remove Lease via omshell

Billy Ng mondeo1055 at yahoo.com
Thu Jan 21 03:24:27 UTC 2010


Hi Glenn,

I can't select the lease by either hardware address or dhcp-client-identifier:

# omshell
> server localhost
> port 7911
> key omapi_key ph5ud2BgMmTYCKmHt7kwEQ==
> connect
obj: <null>
> new lease
obj: lease
> set hardware-address = 00:0e:7f:7c:2c:01
obj: lease
hardware-address = 00:0e:7f:7c:2c:01
> open
can't open object: more than one object matches key
obj: lease
hardware-address = 00:0e:7f:7c:2c:01

# omshell
> server localhost
> port 7911
> key omapi_key ph5ud2BgMmTYCKmHt7kwEQ==
> connect
obj: <null>
> new lease
obj: lease
> set dhcp-client-identifier = 01:00:0e:7f:7c:2c:01
obj: lease
dhcp-client-identifier = 01:00:0e:7f:7c:2c:01
> open
can't open object: more than one object matches key
obj: lease
dhcp-client-identifier = 01:00:0e:7f:7c:2c:01

I'm able to select the lease by IP address but it is failed to remove the lease:

# omshell
> server localhost
> port 7911
> key omapi_key ph5ud2BgMmTYCKmHt7kwEQ==
> connect
obj: <null>
> new lease
obj: lease
> set ip-address = x.x.x.x
obj: lease
ip-address = x:x:x:x
> open
obj: lease
ip-address = x:x:x:x
state = 00:00:00:02
dhcp-client-identifier = 01:00:0e:7f:7c:2c:01
client-hostname = "winxp"
subnet = 00:00:00:03
pool = 00:00:00:04
hardware-address = 00:0e:7f:7c:2c:01
hardware-type = 00:00:00:01
ends = 4b:57:ca:eb
starts = 4b:57:c3:e3
tstp = 4b:57:d5:77
tsfp = 4b:56:df:5c
atsfp = 00:00:00:00
cltt = 4b:57:c3:e3
flags = 00
> remove
can't destroy object: not implemented
obj: lease
ip-address = x:x:x:x
state = 00:00:00:02
dhcp-client-identifier = 01:00:0e:7f:7c:2c:01
client-hostname = "winxp"
subnet = 00:00:00:03
pool = 00:00:00:04
hardware-address = 00:0e:7f:7c:2c:01
hardware-type = 00:00:00:01
ends = 4b:57:ca:eb
starts = 4b:57:c3:e3
tstp = 4b:57:d5:77
tsfp = 4b:56:df:5c
atsfp = 00:00:00:00
cltt = 4b:57:c3:e3
flags = 00

Would you please kindly advise how can I remove the leave by hardware address. Many thanks.

Best Regards,
Billy



________________________________
寄件人﹕ Glenn Satchell <glenn.satchell at uniq.com.au>
收件人﹕ Users of ISC DHCP <dhcp-users at lists.isc.org>
傳送日期﹕ 2010/1/20 (三) 7:00:58 PM
主題: Re: Re: Re: Re: Remove Lease via omshell

Billy Ng wrote:
> Hi All,
> 
> Any idea?
> 
> Best Regards,
> Billy
> 
> ------------------------------------------------------------------------
> *寄件人﹕* Billy Ng <mondeo1055 at yahoo.com>
> *收件人﹕* Users of ISC DHCP <dhcp-users at lists.isc.org>
> *傳送日期﹕* 2009/12/29 (二) 10:25:17 AM
> *主題:* Re: Re: Remove Lease via omshell
> 
> Dear All,
> 
> When I tried to remove the lease from omshell by:
> 
> omshell
>>server localhost
>>port 7911
>>key my_key xxxxxx
>>new host
>>set name = "HOSTNAME"  
> (where the HOSTNAME is the client-hostname listed in the dhcpd.lease)
>>open
> can't open object: not found
> obj: host
> name = "HOSTNAME"
>>remove
> can't destroy object: not found
> obj: host
> name = "HOSTNAME"
> 
> Any idea?
> 
> Best Regards,
> Billy
> 
> ------------------------------------------------------------------------
> *寄件人﹕* Glenn Satchell <Glenn.Satchell at uniq.com.au>
> *收件人﹕* dhcp-users at lists.isc.org
> *傳送日期﹕* 2009/12/7 (一) 7:24:05 PM
> *主題:* Re:Re: Remove Lease via omshell
> 
> They are in /etc/dhcpd.conf, so you could either hard code them in your
> script, or use some grep and cut to extract them from dhcpd.conf into
> shell variables which you plug into your omshell command line.
> 
> Something like this:
> 
> #! /bin/sh
> PORT=`grep port /etc/dhcpd.conf | cut -f2 | sed -e 's/;//'`
> # repeat for other vars like secret and keyname
> 
> omshell << EOF
> server localhost
> port $PORT
> key $keyname $secret
> connect
> new host
> set name = "hostname"
> open
> remove
> EOF
> 
> regards,
> -glenn
> 
>  >Date: Mon, 7 Dec 2009 18:59:15 +0800 (CST)
>  >From: syhshanda <syhshanda at 126.com <mailto:syhshanda at 126.com>>
>  >
>  > Hi,
>  >  In the command line of "key keyname secret", how can I get the 
> keyname and
> secret.
>  >  Thanks for you help.
>  > Best Regards,
>  > Bob
>  >
>  >
>  >
>  >
>  >
>  >
>  > 婓2009-12-07?12:07:25ㄛApu?<apu at spfld.com <mailto:apu at spfld.com>>?迡耋ㄩ
>  > >On?12/6/09?10:30?PM,?Billy?Ng?wrote:
>  > >>?Is?it?possible?to?remove?a?lease?via?omshell??If?yes,?would?you
>  > >>?please?kindly?advise?the?syntax?of?omshell??Thanks?a?lot.
>  > >
>  > >
>  > >    server?localhost
>  > >    port?7911
>  > >    key?keyname?secret
>  > >    connect
>  > >    new?host
>  > >    set?name?=?"hostname"
>  > >    open
>  > >    remove
>  > >
>  > >
>  > >--?
>  > >Apu?<apu at spfld.com <mailto:apu at spfld.com>>
>  > >http://www.spfld.com/
>  > >
>  > >
>  > >_______________________________________________
>  > >dhcp-users?mailing?list
>  > >dhcp-users at lists.isc.org <mailto:dhcp-users at lists.isc.org>
>  > >https://lists.isc.org/mailman/listinfo/dhcp-users
> 
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org <mailto:dhcp-users at lists.isc.org>
> https://lists.isc.org/mailman/listinfo/dhcp-users
> 
> ------------------------------------------------------------------------
> Yahoo!香港提供網上安全攻略,教你如何防範黑客!*了解更多* 
> <http://hk.promo.yahoo.com/security/>
> 
> ------------------------------------------------------------------------
> Yahoo!香港提供網上安全攻略,教你如何防範黑客!*了解更多* 
> <http://hk.promo.yahoo.com/security/>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users

After specifying server, port and key, you must connect to the dhcp
server. Whenever an error is returned, there is no point in continuing,
so in your example after not being able to open the remote host, there
is no way to remove it.

Here's an example that does work, cut and paste from my system. This is
selecting by ip-address. In my earlier post I mistakenly put "name" as
the key to match on. The correct variable is "client-hostname" but I
don't think it can be used as a key to match on. Sorry about any
confusion I caused.

% omshell
> server localhost
> port 7911
> key OMAPI xxxxxx
> connect
obj: <null>
> new host
obj: host
> set ip-address = 192.168.14.231
obj: host
ip-address = c0:a8:0e:e7
> open
obj: host
ip-address = c0:a8:0e:e7
name = "ripper"
hardware-address = 00:90:27:19:22:c2
hardware-type = 00:00:00:01
> remove
obj: <null>
> ^D

Note that when you use a host object, you don't match against things in
the leases database, but rather things with host statements in
dhcpd.conf. To match against dynamic entries you need to match against a
lease. To match a lease you must use the ip-address, hardware-address or
dhcp-client-identifier as the key to match on.

Select a lease by ip-address:
% omshell
> server localhost
> port 7911
> key OMAPI HgEqjc76U4FAfn4F5EEuPw==
> connect
obj: <null>
> new lease
obj: lease
> set ip-address = 192.168.14.230
obj: lease
ip-address = c0:a8:0e:e6
> open
obj: lease
ip-address = c0:a8:0e:e6
state = 00:00:00:01
subnet = 00:00:00:0b
pool = 00:00:00:0c
hardware-address = 00:0d:60:1a:c4:fa
hardware-type = 00:00:00:01
ends = 4a:fe:ba:41
starts = 4a:fd:68:c1
tstp = 4a:fe:ba:41
tsfp = 00:00:00:00
atsfp = 00:00:00:00
cltt = 4a:fd:68:c1
flags = 00
vendor-string = "SUNW.i86pc"

Select a lease by ethernet address:
% omshell
> server localhost
> port 7911
> key OMAPI HgEqjc76U4FAfn4F5EEuPw==
>
> connect
obj: <null>
> new lease
obj: lease
> set hardware-address = 00:90:27:19:22:c2
obj: lease
hardware-address = 00:90:27:19:22:c2
> open
obj: lease
hardware-address = 00:90:27:19:22:c2
state = 00:00:00:01
ip-address = c0:a8:0e:e7
dhcp-client-identifier = 01:00:90:27:19:22:c2
...

Select a lease by client-id:
% omshell
> server localhost
> port 7911
> key OMAPI HgEqjc76U4FAfn4F5EEuPw
> connect
obj: <null>
> new lease
obj: lease
> set dhcp-client-identifier = 01:00:90:27:19:22:c2
obj: lease
dhcp-client-identifier = 01:00:90:27:19:22:c2
> open
obj: lease
dhcp-client-identifier = 01:00:90:27:19:22:c2
state = 00:00:00:01
ip-address = c0:a8:0e:e7
...
> remove
can't destroy object: not implemented
obj: lease
dhcp-client-identifier = 01:00:90:27:19:22:c2
...
> ^D

I hope this helps a bit, even though it is not a complete answer.

-- 
regards,
-glenn
--
Glenn Satchell                            |  Miss 9: What do you
Uniq Advances Pty Ltd, Sydney Australia   |  do at work Dad?
mailto:glenn.satchell at uniq.com.au         |  Miss 6: He just
http://www.uniq.com.au tel:0409-458-580   |  types random stuff.
_______________________________________________
dhcp-users mailing list
dhcp-users at lists.isc.org
https://lists.isc.org/mailman/listinfo/dhcp-users


      Yahoo!香港提供網上安全攻略,教你如何防範黑客! 請前往 http://hk.promo.yahoo.com/security/ 了解更多!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20100120/d9c4f8f2/attachment.html>


More information about the dhcp-users mailing list