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

IPv4 address reserve creation is not working

New Member
Posts: 2
1574     0

Hi team!

 

I am trying to add a ipv4 reservation to an IP address using the infoblox API. I am using the following code:

 

def reserve_ip_addr(self, address, name, comment):
		""" Implements IBA REST API call to reserve IBA IPv4 address 
		Returns None 
		:param address: IP v4 address in CIDR format without subnet
			:param name: reservation name
			:param comment: context 
		"""
		attr= lambda key, val: '"' + key + '":' + '"' + val + '"'
		extattr = lambda key, val: '"' + key + '":' + '{"value":"' + val + '"}'
		rest_url = 'https://' + self.iba_host + '/wapi/v' + self.iba_wapi_version + '/ipv4address'
		payload = '{' + attr("ipv4addr", address) + ',' + \
		attr("names", name) + \
		'}'
		# example extattrs

		#'"extattrs": {' + \
		#extattr("Editor", editor) + "," + \
		'}'
		print payload
		r = requests.post(url=rest_url, auth=(self.iba_user, self.iba_password), verify=self.iba_verify_ssl, data=str(payload))
		r_json = r.json()
		try:
			print r.json()
			if r.status_code == 200 or r.status_code == 201:
				return
			else:
				if 'text' in r_json:
					raise InfobloxGeneralException(r_json['text'])
				else:
					r.raise_for_status()
		except ValueError:
			raise Exception(r)
		except Exception:
			raise
	

I am getting the next error:

Operation create not allowed for ipv4address

 

Any suggestion?

 

Re: IPv4 address reserve creation is not working

Moderator
Moderator
Posts: 306
1575     0

The object type you want to create is a 'fixedaddress' object. 

 

The rest_url line should look something like this;

 

		rest_url = 'https://' + self.iba_host + '/wapi/v' + self.iba_wapi_version + '/fixedaddress

for a DHCP Fixed Address, use the real client's MAC address.

 

For a DHCP Reservation, use a MAC address of all-zeros:

 

"mac": "00:00:00:00:00:00",

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You