omshell: querying host info via ip address
Jeff Waller
jeffw at cnxntech.com
Mon Mar 5 14:51:31 UTC 2012
Well this is from version 4.2 but I doubt things have changed much, this is the
server source that finds a host entry based on the ip address.
==========
status = omapi_get_value_str (ref, id, "ip-address", &tv);
if (status == ISC_R_SUCCESS) {
struct lease *l;
/* first find the lease for this ip address */
l = (struct lease *)0;
lease_ip_hash_lookup(&l, lease_ip_addr_hash,
tv->value->u.buffer.value,
tv->value->u.buffer.len, MDL);
omapi_value_dereference (&tv, MDL);
if (!l && !*lp)
return ISC_R_NOTFOUND;
if (l) {
/* now use that to get a host */
host = (struct host_decl *)0;
host_hash_lookup (&host, host_hw_addr_hash,
l -> hardware_addr.hbuf,
l -> hardware_addr.hlen, MDL);
==========
Apparently, the lease is used to find sufficient information (the mac address)
to find the host, but I wonder, if that host has not made a request yet, will there
be a lease? As an experiment, could you have that host acquire an IP and then
make the query. Not sure how to fix yet as there is no host_ip_hash.
-Jeff
On Mar 4, 2012, at 9:45 AM, Will Green wrote:
> Hello,
>
> I'm trying to manage DHCP entries with omshell, but have hit a
> problem. I am using CentOS 6.2 with isc-dhcpd-4.1.1-P1.
>
> My leases file contains one entry:
>
> host foo {
> dynamic;
> hardware ethernet 08:00:27:2b:fc:e1;
> fixed-address 172.16.1.99;
> }
>
> When I try to query the server about host records I can only find the
> host by name or hardware-address, attempts to look it up via IP
> address fail. What am I missing? omshell output below shows what
> happens:
>
> $ omshell
>> key (hidden in email)
>> connect
> obj: <null>
>> new host
> obj: host
>> set name = "foo"
> obj: host
> name = "foo"
>> open
> obj: host
> name = "foo"
> ip-address = ac:10:01:63
> hardware-address = 08:00:27:2b:fc:e1
> hardware-type = 00:00:00:01
>> close
> obj: <null>
>> new host
> obj: host
>> set hardware-address = 08:00:27:2b:fc:e1
> obj: host
> hardware-address = 08:00:27:2b:fc:e1
>> open
> obj: host
> hardware-address = 08:00:27:2b:fc:e1
> ip-address = ac:10:01:63
> name = "foo"
> hardware-type = 00:00:00:01
>> close
> obj: <null>
>> new host
> obj: host
>> set ip-address = 172.16.1.99
> obj: host
> ip-address = ac:10:01:63
>> open
> can't open object: not found
> obj: host
> ip-address = ac:10:01:63
>
> TIA,
> Will
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users
More information about the dhcp-users
mailing list