THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

Create a report used/unused ips in multiples subnets

New Member
Posts: 5
6773     0

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,

Re: Create a report used/unused ips in multiples subnets

New Member
Posts: 5
6774     0

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

Superuser
Posts: 38
6774     0

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

 

 

Shukran

Re: Create a report used/unused ips in multiples subnets

Moderator
Moderator
Posts: 315
6774     0

"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

New Member
Posts: 5
6774     0

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

New Member
Posts: 1
6774     0

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

Superuser
Posts: 38
6774     0

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"
        }
    }
]'
Shukran

Re: Create a report used/unused ips in multiples subnets

New Member
Posts: 5
6774     0

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

New Member
Posts: 2
6774     0

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

Moderator
Moderator
Posts: 315
6774     0

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

New Member
Posts: 2
6774     0

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 ]
New Member
Posts: 1
6774     0

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.

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