Infoblox REST API with Perl


I recently had the need to add a couple of thousand host objects to our Infoblox IPAM solution since we were missing almost all our store routers, switches, wireless switches, APC UPS, printers, etc. With over 500+ stores and not having any interns available I wasn’t looking for to the challenge of navigating the WEB UI within Infoblox to create over 2,500+ objects. Instead I decided to let the computer do the work and I wrote a quick and dirty little Perl script that could essentially loop over the subnets in a /16 network and create the host objects for each device one at a time. This isn’t particularly pretty but it got the job done for me and I’m posting it here in hopes that it will help someone else traveling the same path.

I started with the following cURL request since I needed to know what format the data had to be in;

curl -k1 -u username:password -H "Content-Type: application/json" -X POST -d '{"ipv4addrs":[{"ipv4addr":""}],"name":"","comment":"HP LaserJet Printer"}'

That cURL request would create a host object at with the name of I took that structure, and built some Perl code around it and got the following script;

# Filename: /usr/local/etc/
# Purpose:  Perl code to create Infoblox host objects utilizing REST API 
#           interface. Used to create DNS objects across multiple subnets.
#           This code will create host objects for all the routers, switches,
#           APC UPS, servers, PC, etc. Since the IP address of those devices
#           utilize the same last octect in each IP subnet and there is a 
#           standard naming convention to easily follow programatically.
# Notes:    This code is really just an example of what's possible using 
#           the Infoblox REST API interface. I don't expect anyone to actually
#           use this code directly, but hopefully they will learn how to 
#           use the REST API interface in Perl through this example.
# Author:   Michael McNamara (
# Date:     April 15, 2016
# Version:  1.0
# License:
#           Copyright (C) 2016 Michael McNamara (
#           This program is free software: you can redistribute it and/or modify
#           it under the terms of the GNU General Public License as published by
#           the Free Software Foundation, either version 3 of the License, or
#           (at your option) any later version.
#           This program is distributed in the hope that it will be useful,
#           but WITHOUT ANY WARRANTY; without even the implied warranty of
#           GNU General Public License for more details.
#           You should have received a copy of the GNU General Public License
#           along with this program.  If not, see 
# Changes:
#  April 30, 2016 (M.McNamara)
#    clean up the code, add license

# Load Modules
use strict;
use warnings;
use utf8;
use REST::Client;
use JSON;
use MIME::Base64;
use Data::Dumper;

# Infoblox username and password
my $username = 'InfobloxUsername';
my $password = 'InfobloxPassword';

# Declare Variables
my $IP;
my $HOST;
my $NUM;

# Declare Infoblox URL
# replace with your Infoblox URL or IP address
my $host = '';

# Declare the HTML headers needed
my $headers = {Content_Type => 'application/json', Accept => 'application/json', Authorization => 'Basic ' . encode_base64($username . ':' . $password)};

# Declare the REST object
my $client = REST::Client->new();

# Link the REST object to the Infoblox URL

# Loop across all the subnets in the /16 network
for (my $i=1; $i<=100; $i++) { 

# The IP is based on which subnet we're loop through 
$IP = "10.246.$i.250"; 

# In some cases it's necessary to perform some arithmetic on the IP 
$NUM = $i - 0; 

# Let's determine what the DNS name should be for this object 
$HOST = sprintf("",$NUM); 

# Let's echo to the screen the IP address and DNS name 
print "IP = $IP \t HOST = $HOST\n"; 

# Let's set the JSON data set we're going to send to the REST API 
my %json_data = ( ipv4addrs => [{
                        ipv4addr => $IP }],
                        name => $HOST,
                        comment => 'HP LasterJet Printer'


	# Let's encode the JSON data before we send it
	my $data = encode_json(\%json_data);

	# Let's call the REST API interface and create the host object
	# Let's decode the result so we can see what happened (if debugging)
	#my $response = decode_json ($client->responseContent());

	# Let's print the respone
	print Dumper( $client->responseContent() );

} #end for





DNS Loops – how to not configure DNS forwarding


I'm continually amazed by how much I don't know and by all the little issues and problems that I encounter in my day to day tasks.  You never know what's going to pop-up. I recently stumbled over a very poorly configured DNS environment and thought I would share how to not configuring DNS forwarding. There was a standalone Microsoft domain which had four domain controllers which were set to forward their requests to another pair of Microsoft DNS servers which eventually forwarded those requests to a fairly new Infoblox DNS environment. Upon looking at the Infoblox reports I noticed a number […] Read More


Launching the Network Broadcast Storm Podcast


Over four years ago I had the idea of trying my hand at a podcast. I enlisted a number of IT professionals from the Network Infrastructure Forums to join me including Dominik Pickhardt, then real life intruded and the project fell idle just before we were going to launch. Since that time Dominik has launched Network Autobahn, which has been a large success due in part to his hard work and efforts. At the recent Networking Field Day 11 I had a frank discussion with Dominik about the possibility of trying to jump start the project and we collectively decided to give it a […] Read More


The past two weeks have been insane thanks to CryptoWall and the many variants that are out in the wild. It started early Monday morning with a UK office, hit the US West coast mid-week and then finally came calling to the US East coast by weeks end. All told we had to restore some 250,000+ files on multiple Windows File Shares from either Shadow Copies or from backups. The bigger issue for us are the Windows File Shares from which the infected clients have mapped drives. So I've spent the past 2 days researching CryptoWall and trying to figure […] Read More


Big Switch Networks – Big Tap Monitoring Fabric


While attending Networking Field Day 11 we stopped in to see the folks from Big Switch Networks. Big Switch has applied their SDN fabric solution to provide a very cost effective means of providing a virtual network tap within the Data Center. We heard from Kyle Forester, Big Switch Founder, and Rob Sherwood, CTO, among others. I walked away with the following quote, I apologize that I didn't write down exactly who said it. We're "getting away from being the dumb plumber".  Big Switch is using their fabric to make multiple copies of traffic and pass those copies to a services […] Read More

{ 1 comment }