- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 10:08 AM
Hello team,
I need to create a report to send to my customer to knwo how many ip address are free/used in every subnet.
I created a report by using splunk in Infoblox -Reporting, but I am trying to automate it.
Can I download it using API?
Like I couldn't find out how, I am trying to get how many ip address are "unused" using python + requests.
This is my code:
args = {"network": network,
"_return_fields": "status",
"status": "UNUSED"
"_return_as_object": 1
}
r = session.get(url_info + 'ipv4address', data=args)
I don't know how to search for multiples networks. I could make a request for subnet, but I have a few hundreds.
I have read some examples but I am getting this error.
{'Error': 'AdmConProtoError: Only the POST method is supported for body-only requests.', 'code': 'Client.Ibap.Proto', 'text': 'Only the POST method is supported for body-only requests.'}
I have tried something like this:
args = [{"method": "GET",
"object": "network",
"data": {"network": "172.20.196.0/27"}},
{"method": "GET",
"object": "network",
"data": {"network": "172.20.197.32/27"}},
{"method": "GET",
"object": "network",
"data": {"network": "172.20.197.64/26"}}]
r = session.get(url_info + 'request', data=json.dumps(args))
Any advice would be welcome.
And any other suggestion would be great, I don't know if there is any other way to get free ips in a subnet.
I just need the number, not details.
I want to get these statistics and create and excel with some plots.
I would like to get this goal with python + requests.
Thanks,
Solved! Go to Solution.
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 03:18 AM
Hello Ursula,
Thanks for your help.
This an example, I have hundreds of subnets to check.
I do not understand your idea.
Anyway, I am receiving an error.
'Error': 'AdmConProtoError: 172.20.196.0/23 does not match any network'
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 07:31 AM
In your original example you are using get method to for requests object and it supports post. Also you are quering network object. The data object in below curl has the ipv4address that you should query.
curl --location --request POST 'https://<grid-master>/wapi/v2.12/request' \ --header 'Content-Type: application/json' \ --data-raw '[{"method": "GET", "object": "ipv4address", "data": { "network": "1.1.1.0/24", "status":"USED" } }, {"method": "GET", "object": "ipv4address", "data": { "network": "10.10.10.0/24", "status":"UNUSED" } }, {"method": "GET", "object": "ipv4address", "data": { "network": "11.1.1.0/24", "status":"UNUSED" } } ]'
The above query should work for you and you could filter out the USED or UNUSED ips by specifying them in the request.
'Error': 'AdmConProtoError: 172.20.196.0/23 does not match any network'
This error gives the impression that the given network is not present in your grid
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 10:35 PM
"Ursula"s message was spam, it was later modified and a URL was added. I've marked it as such. Sorry you got gotten.
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2022 04:42 AM
That's it!
Thanks!!
Just one thing, Could I filter the output to get just needed fields?
It is just to get only needed fileds to speed parsing that output.
I tried adding "_return_fields" in data but I get an error.
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2022 05:16 AM
I think you are having this error because there no such feature is available to filter output or there no way to do it.
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2022 09:10 AM
You can filter out the output using "_return_fields", you just need to pass it in the args along with the rest of the request body.
Below is a curl for your reference.
curl -L -X POST 'https://<grid-ip>/wapi/v2.12/request' \ -H 'Content-Type: application/json' \ --data-raw '[ { "method": "GET", "object": "ipv4address", "data": { "network": "1.1.1.0/24", "status": "USED" }, "args": { "_return_fields": "status" } }, { "method": "GET", "object": "ipv4address", "data": { "network": "10.10.10.0/24", "status": "USED" }, "args": { "_return_fields": "status,network" } } ]'
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2022 02:09 AM
Hello shukran,
I created the request like this:
{'args': {'_return_fields': 'status'},
'data': {'network': '10.71.80.0/24', 'status': 'USED'},
'method': 'GET',
'object': 'ipv4address'}]
It works great and that was really was I requested, but I am getting this error:
{'Error': 'AdmConProtoError: Result set too large (> 1000)',
'code': 'Client.Ibap.Proto',
'text': 'Result set too large (> 1000)'}
I could try to chunk the list to get partial results, but I was wondering if I could just get the number of used/unused ips addresses.
I don't need all the details that I am getting for every ip address, just need to know how many ip addresses are free in every subnet.
Is there any way to achieve this?
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2022 02:33 AM
I am trying to request all unused IP addresses, but everything I try doesn't work. The request below is that what I mostly found should return all unused IPS in the given network, but I always just get a blank Array.
I could imagine it does come from the old WAPI version. But I think I've seen this exact request with an even older version.
Request:
https://<grid-master>/wapi/v2.10.5/ipv4address?network=10.10.10.0/24&status=UNUSED
Response:
[]
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 06:55 PM
That call is working for me. Make sure the account you're using has permissions to see it and its contents?
Re: Create a report used/unused ips in multiples subnets
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 03:56 AM
I don't know why I never thought about this, but now it works. Thanks a lot.
Re: Create a report used/unused ips in multiples subnets
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2023 09:51 AM - edited 12-23-2023 12:37 AM
Generating a comprehensive IP report involves meticulous subnet scanning. Utilize tools like Nmap or subnet calculators to identify used and unused IPs. Documenting this information aids network optimization, security, and resource allocation. Regularly updating such reports ensures an accurate representation of the network's dynamic landscape.