Reply

API get DHCP lease related info

New Member
Posts: 4
16416     0

Hi,

     I want use API to obtain DHCP lease ip all related info , need include lease allocation and end time .
I can not found this from API guide , so is this possible ? If yes , what API can help achieve ?

 

Any help will be appreciated.

Re: API get DHCP lease related info

Moderator
Moderator
Posts: 315
16417     0

 

curl -k1 -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.2/lease?_return_fields%2b=address,starts,ends,tstp,binding_state,hardware,uid&_return_as_object=1'



If there's a large number of leases, you will need to request them in pages.  Here's how you request them 10 at a time.  (10 is good for an example, 1000 is more realistic in an automated script...)

curl -k -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.2/lease?_return_fields%2b=address,starts,ends,tstp,binding_state,hardware,uid&_paging=1&_return_as_object=1&_max_results=10'



which returns:

{
    "next_page_id": "789c5...",
    "result": [
    ...
    <lots of leases>
    ...
 }


For next page, use that next_page_id value in the request:

curl -k -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.2/lease?_return_as_object=1&_max_results=100&_paging=1&_page_id=789c5...'

   
This returns another next_page_id, which goes into the next page request.  repeat until next_page_id is empty, this means all pages have been returned

 

Re: API get DHCP lease related info

New Member
Posts: 4
16417     0

Dear MRichard,

       Many thank your reply ! You reply is helpful !

 

        But i am confusing about API return lease Start and End time . I can not match return value with lease real time .

 

For example :

In my lab , lease  Start time is :2018-07-16 10:35:06 CST ,

and lease End time is :2018-07-16 22:35:06 CST  ;

 

But API return lease Start and End time is strange number:

 

<list>
<value type="object">
<ends type="int">1531751706</ends>
<starts type="int">1531708506</starts>
<client_hostname>Lab-XP1</client_hostname>
<hardware>00:0c:29:3f:1b:bc</hardware>
<binding_state>ACTIVE</binding_state>
<_ref>
lease/ZG5zLmxlYXNlJDEwLzE5Mi4xNjguMjAuMTAwLzAv:192.168.20.100/default
</_ref>
</value>
</list>

 

Do you know how to match these API return "int number" with lease real time ?

 

 

Regards,

King

Re: API get DHCP lease related info

Techie
Posts: 3
16417     0
Hi King, You can use https://www.epochconverter.com/ to convert the epodch to human readable data and time. BR, Simon
Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin