Reply

DHCP Leases by network CIDR

Authority
Posts: 12
3805     0

Hello,

 

I'm looking for something rather simple, but a way in the WAPI to:

 

"Give me all live leases in network x.y.z.q/mm"

 

I have a workaround currently whereby I dump the entire list of all leases in Infoblox and using python netaddr, filter out those that are within the particular CIDR block I'm looking for.  Although "network" is a field in the lease object, it cannot be used for searching in version 2.9. I would be fine even if I could squelch the master list of all leases to just those with the first 2 octets, which would likely speed up things, considering my current script takes 5 minutes to run to return a networks' worth of leases.

 

Is there another way?

 

Thanks

 

 

Re: DHCP Leases by network CIDR

Moderator
Moderator
Posts: 321
3806     0

You can get a list of the lease objects using an IPAM approach:

 

curl -k1 -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.9/ipv4address' -H "Content-Type: application/json" -d \
'{
  "network": "10.102.0.0/16", 
  "status": "USED", 
  "types": "LEASE"
}'

You will get a list of results like this:

 

[
    {
        "_ref": "ipv4address/Li5pcHY0X2FkZHJlc3MkMTAuMTAyLjEwMC4xMDYvMA:10.102.100.106", 
        "ip_address": "10.102.100.106", 
        "is_conflict": false, 
        "lease_state": "BACKUP", 
        "mac_address": "00:50:56:83:15:09", 
        "names": [], 
        "network": "10.102.0.0/16", 
        "network_view": "default", 
        "objects": [
            "lease/ZG5zLmxlYXNlJDAvMTAuMTAyLjEwMC4xMDYvMC8:10.102.100.106/default", 
            "lease/ZG5zLmxlYXNlJDcvMTAuMTAyLjEwMC4xMDYvMC8:10.102.100.106/default"
        ], 
        "status": "USED", 
        "types": [
            "LEASE", 
            "DHCP_RANGE"
        ], 
        "usage": [
            "DHCP"
        ]
    }, 
...
]

If you need specifics on the individual leases you can load them separately.

 

Note I'm using DHCP Failover so there are two leases recorded per IP + MAC address, one for each appliance in the HA pair.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You