- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 03:15 AM
Hi All
I am trying to get the next availble IP for a subnet and reserve it.
https://ddi.sss.test.net/wapi/v2.10.5/network/ZG5zLm5ldHdvcmskMTAuMTI0LjExLjAvMjcvMA:10.124.11.0/27/default?_function=next_available_ip&_return_as_object=1 -d {num:1}
But it is giving me error like below
"Error": "AdmConProtoError: Invalid value for _return_as_object: 1 -d {num:1}", "code": "Client.Ibap.Proto", "text": "Invalid value for _return_as_object: 1 -d {num:1}"
i tried changing things but getting different different errors. taken the _ref for the subnet also.
Please help me in this.
Solved! Go to Solution.
Re: Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 04:06 AM
Hi,
You would need to do a POST operation to get the next available IP.
curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://grid- master/wapi/v2.11/network/ZG5zLm5ldHdvcmskMTcyLjIxLjEwLjAvMjQvMA:172.21.10.0/24/default?_function =next_available_ip&_return_as_object=1" -d '{"num":1}'
You can find the example here.
Hope this is helpful,
Thanks & Regards,
Krishna
Re: Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 04:15 AM
Thanks for your response. but i am usign postman for the request and when i am adding
-d '{"num":1}'
at the end i am getting below error:
"Error": "AdmConProtoError: Invalid value for _return_as_object: 1 -d '{\"num\":1}' ", "code": "Client.Ibap.Proto", "text": "Invalid value for _return_as_object: 1 -d '{\"num\":1}' "
Re: Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 04:32 AM
Hi,
In case of Postman, you would have to specify this in the Body section, and not as part of the URL.
Regards,
Krishna Vasudevan
Re: Next vaialble ip for a subnet
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 04:45 AM - edited 09-02-2021 04:46 AM
I'd recommend a multiple body request, to retrieve the container ref and generate the new network, all in a single call.
Also I'd recommend using Postman variables for the gridmaster IP and WAPI version so they can be adjusted as needed for all calls.
The request type is POST and the url is https://{{gridmaster}}/wapi/{{version}}/request
The body is:
[ { "method":"GET", "object":"networkcontainer", "data": { "network": "10.0.0.0/8" }, "assign_state": {"my_ref": "_ref" }, "enable_substitution": true, "discard": true }, { "method":"POST", "object": "network", "enable_substitution": true, "data": { "network": "func:nextavailablenetwork:##STATE:my_ref:##,24", "comment": "Created by Next Available Network" } } ]
Here's what it looks like in Postman, with a successful response shown in the response body:
Re: Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 04:52 AM
Thanks for the response @krishna. one more thing i need help is same request further i will use this url in powershell script like below
$url = "https://ddi.sss.st-gin.net/wapi/v2.10.5/network" $Result = Invoke-RestMethod -Uri $url -Method Get -Credential $creds -Headers $headers -ContentType 'application/json'
So in this case where i have to mention the in the body, so how to do that
num:1
Re: Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 04:59 AM
Hi,
You would need to specify it as part of the body parameter.
$url = "https://grid-master/wapi/v2.11/network/ZG5zLm5ldHdvcmskMTkyLjE2OC4xMS4wLzI0LzA:192.168.11.0/24/default?_function=next_available_ip" $pwd = ConvertTo-SecureString "pwd" -AsPlainText -Force $creds = New-Object Management.Automation.PSCredential ('admin', $pwd) $num_details = @{ num=1} $body = $num_details | ConvertTo-Json Invoke-RestMethod -Uri $url -Method POST -Credential $creds -ContentType 'application/json' -Body $body
Regards,
Krishna
Re: Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2021 05:07 AM
Thanks a lot @Krishna for your help.
Re: Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 07:42 AM
Do you know if the next_available_ip function is getting the IP address from the IP range specified in the DHCP scope?
The reason for my question is that I am getting "Cannot find 1 available IP address(es) in this network." error but we are seeing a lot of available IP addresses in the UI > IPAM view.
Re: Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 11:27 PM
Hi!
Is't possible to use tags to fetch next availible IP address in some way? My thoughtwas to tag multiple network and from query tag IPAM fetch next availible ip from those network that is taged equal.
Or if there is any other way of doing im very much interested.
Thanks in advance
Patric
Re: Next vaialble ip for a subnet
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 10:16 AM
You can do this using the multiple body request discussed above. In this example, I search on tow EAs, Site and Building, to identify the network and then find the next available IP in that network:
[ { "method": "GET", "object": "network", "data": { "*Site": "HQ", "*Building": "Two" }, "assign_state": { "netw_ref": "_ref" }, "discard": true }, { "method": "POST", "object": "##STATE:netw_ref:##", "args": { "_function": "next_available_ip" }, "enable_substitution": true } ]