Reply
Highlighted
Accepted Solution

Get specific, narrowest subnet, with IP address as input

[ Edited ]
burvil
Techie
Posts: 12
2717     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: 19
2718     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

burvil
Techie
Posts: 12
2718     0

Yes, that works.  Thanks.  

Showing results for 
Search instead for 
Do you mean 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin