Infoblox’s global team of threat hunters uncovers a DNS operation with the ability to bypass traditional security measures and control the Great Firewall of China. Read about “Muddling Meerkat” and the many other threat actors discovered by Infoblox Threat Intel here.

API & Integration, DevOps,NetOps,SecOps

Reply

Single REST call for creating a host object

Authority
Posts: 11
2944     0

I have to make a generic call to create a record:host in networks with and without DHCP ranges defined.

 

I can do it with 2 separate calls and error detection like:

 

newhostname=newhost.test

oldhostname=oldhost.test

 

# For network WITH DHCP

curl -s --negotiate -u : -H "Content-Type: application/json" -X POST "https://ibx/wapi/v2.10.3/request" -d '[{"method": "GET", "object": "network", "data": {"contains_address":"'"$(dig $oldhostname +short)"'"},"assign_state": {"netw_name": "network"},"discard": true},{"method": "GET", "object": "range", "data": {"network": "##STATE:netw_name:##"},"assign_state": {"range_ref": "_ref"},"discard": true,"enable_substitution": true},{"method": "POST", "object": "##STATE:range_ref:##", "args": {"_function": "next_available_ip"}, "data":{"num":1},"enable_substitution": true,"assign_state": {"next": "ips[0]"},"discard": false},{"method": "POST", "object": "record:host", "data": {"name": "'"$newhostname"'", "ipv4addrs": [{"ipv4addr": "##STATE:next:##"}]}, "enable_substitution": true}]'

 

#For network WITHOUT DHCP

curl -s --negotiate -u : -H "Content-Type: application/json" -X POST "https://ibx/wapi/v2.10.3/request" -d '[{"method": "GET", "object": "network","data": {"contains_address":"'"$(dig $oldhostname +short)"'"},"assign_state": {"netw_ref": "_ref"},"discard": true},{"method": "POST","object": "##STATE:netw_ref:##","args": {"_function": "next_available_ip"}, "data":{"num":1},"enable_substitution": true,"assign_state": {"next": "ips[0]"},"discard": false},{"method": "POST", "object": "record:host", "data": {"name": "'"$newhostname"'", "ipv4addrs": [{"ipv4addr": "##STATE:next:##"}]}, "enable_substitution": true}]'

 

 

 

So question is, how to combine those calls to pick next available IP on the network where given host exists and make a record:host for it?

Re: Single REST call for creating a host object

Moderator
Moderator
Posts: 289
2944     0

Is your intention to create the host within the range, when one exists, or to avoid the range?

 

If you want to avoid the range, the next_available_ip function will already do that for you.  No need to look up the range, just run the next_available_ip function against the network.

 

 

 

Re: Single REST call for creating a host object

Authority
Posts: 11
2944     0

Want to be within the range. Look up the host, provision another one next to it.

Re: Single REST call for creating a host object

New Member
Posts: 1
2944     0

Great post. Thanks for the information

Re: Single REST call for creating a host object

New Member
Posts: 1
2944     0

Great Information.Thanks for sharing

Showing results for 
Search instead for 
Did you mean: 

Recommended for You