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.

Automation Scripts


Creating DHCP range structure error

New Member
Posts: 2
2780     0

I'm trying to create an DHCP range and adding a member that will serve the dhcp range to the clients but i keep getting a structure error. I use the python infoblox-client.

Can someone point me in the right direction?


def create_dhcp_range(api_blox, config_obj, site, name):
Create a DHCP range.

api_blox (infoblox_client.connector.Connector): Infoblox API connector object.
config_obj: Configuration object with DHCP range information.
site (dict): Site information.
name (str): Name of the DHCP range.

subnet_key = f"{name}-ipv4_subnet"
if subnet_key not in site:
print(f"Subnet key '{subnet_key}' not found in site dictionary. Skipping DHCP range creation.")
return None

vn = config_obj.vn_list.split(',')
subnet = ipaddress.IPv4Network(site[subnet_key])
start_ip = subnet.network_address + 2
end_ip = subnet.network_address + 30

dhcp_settings = {
"start_addr": str(start_ip),
"end_addr": str(end_ip),
"name": f"{name}-{site['siteName'].split('-')[-1].strip()}",
"comment": f"{name} in {vn if name == 'AP_VLAN' else site['siteName']}",
"member": [
{'name': config_obj.member2, '_struct': 'dhcpmember'}
"server_association_type": "MEMBER",
"restart_if_needed": True
# "failover_association": "IPv4 DHCP Failover Association (ANET-Failover-Group)" (production code)

dhcp_range = objects.IPRangeV4.create(api_blox, update_if_exists=True, **dhcp_settings)
if dhcp_range:
print("DHCP range created successfully.")
except exceptions.InfobloxCannotCreateObject as e:
print(f"Failed to create DHCP range: {str(e)}")

Re: Creating DHCP range structure error

New Member
Posts: 2
2781     0

Found the solution! The member is not a list as it is in the network creation object. So i removed that and now it works.

Re: Creating DHCP range structure error

[ Edited ]
Posts: 10
2781     0



What WAPI version are you using?  


I am trying to create/reserve a new dhcp range, with an assigned dhdp server, in IPAM, with the following parameters, but I can't see the dhcp configs shown in IPAM (ie, don't see my dhcp server assigned to the Member Assignment, for a target subnet, and no IP reservations in the Data Management's Go To DHCP View for the target subnet either).


I've been looking into the documentaiton.  Are you trying to do the same thing?  Does what I used (below) look right to you?


url = f"{url}/range"
ms_server = ""
params = {
"start_addr": start_addr,
"end_addr": end_addr,
"ms_server": {"_struct": "msdhcpserver", "ipv4addr": ms_server},
"name": name,
Showing results for 
Search instead for 
Did you mean: 

Recommended for You