- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
DHCP Leases by network CIDR
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 11:50 AM
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
Solved! Go to Solution.
Re: DHCP Leases by network CIDR
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 04:46 AM
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.