- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Get Next Available IP and Reserve
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-09-2016 01:53 PM
Does the WAPI allow a single call to get the next available IP and Reserve?
VitalQIP had an API call that would return the next available IP address and immediately reserve it if desired. This is great way to avoid potential race conditions.
I was able to request the next available IP in InfoBlox via:
/network/<reference>?_function=next_available_ip&num=1
but I don't see any way to immediately reserve it. Is this possible?
Thank you.
Richard
Solved! Go to Solution.
Re: Get Next Available IP and Reserve
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-09-2016 02:02 PM
This is definitely possible. I shamelessly stole this example from the "Definitive list of REST examples" post here:
https://community.infoblox.com/t5/API-Integration/The-definitive-list-of-REST-examples/td-p/1214
Add a HOST with next_available IP address from a network POST /wapi/v1.2/record:host Content-Type: application/json { "name":"wapi.test.org", "ipv4addrs":[ { "ipv4addr":"func:nextavailableip:10.1.1.0/24" } ] }
You can do this with almost any kind of record that uses the "ipv4addr" field such as a fixed address, Host record, A record, etc. There are more details in the post I linked above.
Re: Get Next Available IP and Reserve
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-09-2016 02:22 PM
Thank you, going to give that a shot!
Re: Get Next Available IP and Reserve
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-12-2016 01:13 PM
Would you happen to know if there is an XML equivelant payload for this?
I tried this, but it doesn't work:
<value type="object"> <name>test.mydomain.org</name> <ipv4addrs> <list> <value type="object"> <ipv4addr>$func:nextavailableip:10.11.12.0/32</ipv4addr> </value> </list> </ipv4addrs> </value>
Error is:
Invalid value for ipv4addr: "$func:nextavailableip:10.11.12.0/32": Invalid IPv4 address
Thank you.
Re: Get Next Available IP and Reserve
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-16-2017 06:31 AM
I get the same error when trying to run that REST call. Has anyone gotten that one to work properly?
Re: Get Next Available IP and Reserve
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-16-2017 12:10 PM
Re: Get Next Available IP and Reserve
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-09-2018 01:32 PM - edited 01-09-2018 02:20 PM
I have been using this function to retrieve IPs from one of our subnets but I've ran into an issue. After making the rest call three times it fails on the fourth with the following error...
"text": "Cannot find 1 available IP address(es) in this range."
This is strange because if I look at the IP Map in the IPAM view through the web console there are at least 25 unused IPs in the subnet. Why does the WAPI say there are none?
Re: Get Next Available IP and Reserve
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-09-2018 07:07 PM
If the message indicates there are no more available addresses in the range, you are likely requesting addresses within a DHCP range or a reserved range, and not within the full network.
Can you post an example of the code you're using?
Re: Get Next Available IP and Reserve
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-10-2018 05:17 AM - edited 01-10-2018 05:18 AM
Sure, I am doing a POST to the url "/fixedaddress?_return_fields=ipv4addr" with the following JSON payload...
{"name": fqdn, "ipv4addr":"func:nextavailableip:10.1.1.11-10.1.1.250", 'mac':'00:00:00:00:00:00'};
I did it this way to skip the first 10 IPs in the subnet. It is a DHCP range but the web console is showing a lot of unused addresses and the WAPI is still complaining that there are none. Maybe I'm completely misunderstanding the meaning of 'unused' in the Infoblox world.
Re: Get Next Available IP and Reserve
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-10-2018 05:26 AM - edited 01-10-2018 05:27 AM
After a little bit more digging I've noticed that the IP addresses that are being picked up from the WAPI call have a Lease state of 'Free' where as all of the other unused IP addresses have a Lease state of 'Abandoned'.
Re: Get Next Available IP and Reserve
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
06-11-2019 05:08 AM
s there a way to get one of the 'Abandoned' ones?
Re: Get Next Available IP and Reserve
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
06-11-2019 08:46 AM
Abandoned leases are only used when free leases have been exhausted. If you are concerned about abandoned leases, you will want to investigate why they are in this state because these indicate that IP conflicts are being detected by the DHCP server or clients and may point to a problem on your network. It could be that a separate device is responding to lease requests and causing conflicts to occur, roque DHCP server on the network, clients that are configured with static IP's from the DHCP range, or even a device that is responding to ping or ARP broadcast requests that are used to determine if an IP is free or in use.
An easy way to tell if you have an actual problem is to clear the abandoned leases and see if they come back again. Starting in NIOS version 8.4.0, this can be done via the CLI:
Infoblox> delete leases without_ends --state ABANDONED
Otherwise, this can be done via script or individually via the GUI.
Regards,
Tony