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

Get specific, narrowest subnet, with IP address as input

[ Edited ]
Techie
Posts: 5
10384     0

Can someone tell me how to use WAPI to get the specific, narrowest subnet, given an IPV4 address as input?

 

In other words, for example, if I have the IP address 10.26.76.121, I want the most specific, narrowly defined CIDR range, which would be 10.26.76.0/22, not any of the subnets it's part of.  In other words, I'd expect to have as an answer to my curl command the string 10.26.76.0/22, not 10.0.0.0/8, not 10.26.64.0/18 or any other subnets that 10.26.76.0/22 is part of.

 

I run the following command and get an empty set, i.e. no results, even though I know upon logging into the Grid Master web interface that it is really 10.26.76.0/22.  

 

$ curl -kl -u username:pw -X GET 'https://infoblox_ip/wapi/v2.7/network?network~=10.26.76.121&_return_fields%2B=network'

 

I am using the format of the command given in an earlier post, https://community.infoblox.com/t5/API-Integration/Find-subnet-given-device-IP/td-p/8033#.  This post was marked as solved, but I think it was marked as such prematurely, as not only did the requestor not get his question answered, but when I try that command here, it fails.

 

That said, if I shorten the command and run 

$ curl -kl -u username:pw -X GET 'https://infoblox_ip/wapi/v2.7/network?network~=10.26.76'

I get the expected response:

 

[
    {
        "_ref": "network/string-removed:10.26.76.0/23/default",
        "network": "10.26.76.0/23",
        "network_view": "default"
    }
]

So, is my only option to get a list of all the subnets and iterate through each and every one until I find the subnet that my IP address is in (using something like what's at https://docs.python.org/3/howto/ipaddress.html)?

 

Anybody know what I'm missing here?

Re: Get specific, narrowest subnet, with IP address as input

Authority
Posts: 4
10385     0

Hi,

 

I got interesting results with the below:

 

curl -k -u admin:infoblox https://grid.master/wapi/v2.7/ipv4address?ip_address=172.16.0.200\&_return_fields=network

 

Response:

 

[
    {
        "_ref": "ipv4address/Li5pcHY0X2FkZHJlc3MkMTcyLjE2LjAuMjAwLzA:172.16.0.200",
        "network": "172.16.0.192/26"
    }
]

 

For the purpose of narrowing down the subnet that an IP address belongs to, the above worked for me.

 

Is this what you had in mind?

 

Re: Get specific, narrowest subnet, with IP address as input

Techie
Posts: 5
10385     0

Yes, that works.  Thanks.  

Re: Get specific, narrowest subnet, with IP address as input

Authority
Posts: 14
10385     0

Hi,

 

https://ipman/wapi/v2.7/ipv4address?ip_address=10.17.117.2\&_return_fields=network

response:
[
    {
        "_ref": "ipv4address/Li5pcHY0X2FkZHJlc3MkMTAuMTcuMTE3LjIvMA:10.17.117.2",
        "network": "10.17.0.0/16"
    }
]

I cant find the exact network for 10.17.117.  instead im getting the overall subnetz.can u help?

Re: Get specific, narrowest subnet, with IP address as input

Adviser
Posts: 181
10385     0

Hi,

 

On the GUI, what is the subnet this IP address belongs to?

 

Can you try this API:

curl -k -u admin:infoblox -X GET "https://grid-master/wapi/v2.7/search?address=10.17.117.2&_return_as_object=1"

Hope this helps,

Krishna Vasudevan

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