- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Get specific, narrowest subnet, with IP address as input
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2019 11:56 AM - edited 02-20-2019 01:16 PM
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?
Solved! Go to Solution.
Re: Get specific, narrowest subnet, with IP address as input
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2019 04:17 PM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2019 03:12 PM
Yes, that works. Thanks.
Re: Get specific, narrowest subnet, with IP address as input
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2020 03:25 AM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2020 12:05 AM
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