Reply

Convert IPv4 address in DHCP range to Fixedaddress object using something like func:nextavailableip

saetling
Techie
Posts: 4
4403     0

 

We have DHCP ranges on most subnets.  We have a customer tool (uses WAPI) that allows them to register devices for fixed DHCP on a particular subnet.  The tool uses the func:nextavailableip:<subnet> function to find an open IP address on that subnet.  When a subnet no longer has open IP addresses we would like to remove an address out of the DHCP range and assign it to the fixedaddress object.  Ideally from either the start or the end of the range to keep the range contiguous.

 

Is there a function to do that?

 

Or is the methodology:

1. detect error from func:nextavailableip

2. lookup range

3. modify range, check for lease ( and delete?)

4. re-run func:nextavailableip

 

Any suggestions?

Re: Convert IPv4 address in DHCP range to Fixedaddress object using something like func:nextavailabl

Adviser
Posts: 136
4404     0

I would setup monitoring/alerting on the particular subnet(s) so that you will know in advance when the available addresses are almost consumed so you can decide how to best allocate additional addresses. Otherwise, eventually you may consume all the addresses from a DHCP range as well.

 

However, you can use the nextavailableip function and specify an existing DHCP range to create a fixed-address from:

 

func:nextavailableip:192.168.1.150-192.168.1.199

 

This would allow you to specify the DHCP range and allocate the next available from here after your script logic determines the other subnet addresses are not available. 

Check out our new Tech docs website at http://docs.infobox.com for latest documentation on Infoblox products

Re: Convert IPv4 address in DHCP range to Fixedaddress object using something like func:nextavailabl

saetling
Techie
Posts: 4
4404     0

Interesting.  I have a /24 with three fixedaddress objects (and host records) at

.1, .2 and .3.  And a dhcp range object start IP = .4  ending IP =  .254.

 

When I issue this curl command

curl -u usernameSmiley Tongueassword \
-k \
-H "Content-Type: application/json" \
-X POST 'https://<gridhostname>/wapi/v2.1/fixedaddress' \
-d '{"mac": "03:03:33:33:33:37", "name": "mac-03-03-33-33-33-37", "match_client": "MAC_ADDRESS" , "ipv4addr": "func:nextavailableip:10.104.255.0/24" }'

 

I get this error:

"AdmConDataError: None (IBDataConflictError: IB.Data.Conflict:Cannot find 1 available IP address(es) in this network.)"

 

When I issue this command, using the range of the DHCP range object:

 curl -u usernameSmiley Tongueassword \
 -k \
 -H "Content-Type: application/json" \
 -X POST 'https://<gridhostname>/wapi/v2.1/fixedaddress' \
 -d '{"mac": "03:03:33:33:33:36", "name": "mac-03-03-33-33-33-36", "match_client": "MAC_ADDRESS" , "ipv4addr": "func:nextavailableip:10.104.255.4-10.104.255.254" }'

 

The fixed address object is created at 10.104.255.4.   However the DHCP range object start IP address is not adjusted.  So now I have a DHCP range object in conflict with a fixedaddress object.

 

That does not seem correct.  I would suggest the behavior should be the same, namely an error.  Or, if creating a fixed address object then the start address of the range object should be changed accordingly.  

 

How would the DHCP service resolve this, if say there was a lease at the conflicting IP address when the fixed DHCP device requested its IP address?

 

Re: Convert IPv4 address in DHCP range to Fixedaddress object using something like func:nextavailabl

Adviser
Posts: 136
4404     0

If there is an active lease, the nextavailableip function should skip this associated IP address and search for the next available. 

 

The range object will not be adjusted as it is now permisable to create a fixed-address within a DHCP range without re-sizing or recreating the range. You can find this same behavior in the GUI as well. 

 

I hope that helps!

Check out our new Tech docs website at http://docs.infobox.com for latest documentation on Infoblox products

Re: Convert IPv4 address in DHCP range to Fixedaddress object using something like func:nextavailabl

Adviser
Posts: 200
4404     0
The reason the first call does not work is because all IP addresses in the subnet are “flagged” as used. The first 3 because you have fixed addresses there and all of the rest because they are “reserved” for use by the DHCP server as a range.

The second call works because you are pulling a “free” (non-leased) IP address from the range itself. This does NOT create a conflict in any way since the DHCP server will automatically adjust the range to skip over any Fixed Addresses that are included inside the range. This enables you to continue to manage the range as one larger range rather than it getting chucked up into a lot of smaller ranges.

Re: Convert IPv4 address in DHCP range to Fixedaddress object using something like func:nextavailabl

[ Edited ]
saetling
Techie
Posts: 4
4404     0

So the solution in this thread works on my test subnet (only defined on test infoblox box, not a 'real' subnet, no actual leases) but does not work on a 'real' subnet in our network.

 curl -u <user>:<pass> \
 -k \
 -H "Content-Type: application/json" \
 -X POST 'https://<infoblox-server>/wapi/v2.1/fixedaddress' \
 -d '{"mac": "ff:04:33:33:33:36", "name": "mac-ff-04-33-33-33-36", "match_client": "MAC_ADDRESS" , "ipv4addr": "func:nextavailableip:10.100.200.10-10.100.200.15" }'

 

Range in question has no leases.   IP addresses in range had lease data showing  'abandoned' lease state, but I cleared even that so lease data showed as 'free' lease state, for all IP addresses in range.

 

Get this error:

{ "Error": "AdmConDataError: None (IBDataConflictError: IB.Data.Conflict:Cannot find 1 available IP address(es) in this range.)",
  "code": "Client.Ibap.Data.Conflict",
  "text": "Cannot find 1 available IP address(es) in this range."
}

 

Any ideas what is going on and how to address?

Re: Convert IPv4 address in DHCP range to Fixedaddress object using something like func:nextavailabl

Adviser
Posts: 136
4404     0

The error message seems to indicate that there are still not any available IP addresses to convert to a fixed address within your range.

 

Even though the current state of your leases are "free", there are likely still historical associations in the lease table preventing these addresses from appearing free from a selection perspective. Take a look at your "current leases" table in the UI and you may see some informaiton related to the IP addresses from this range although they are in a "free" state.

 

Also, take a look at Lease Scavenging under the Grid DHCP configuration. You can enable this to remove the old lease association data after a period of time. This would help keep your database size down and also keep the "stale" entries more clean and likely allow you to assign/re-use the IP addresses in the range programatically. 

 

You could also try increasing the size of your range or testing against another range to validate there is not another issue.

 

 

Check out our new Tech docs website at http://docs.infobox.com for latest documentation on Infoblox products
Showing results for 
Search instead for 
Do you mean 

Recommended for You