03-28-2016 09:59 AM - edited 03-28-2016 10:00 AM
I’m trying to get all the objects/records associated to a zone. To accomplish this, I’m using the export function on the PAPI API “Infoblox:: DNS::AllRecords” (which is good).
Now, if I want to get the networks and network containers of those objects, will I have to run separate APIs (like, Infoblox:: DHCP::Network) on each object (in a loop) or is there any API to get all those information in 1 export file?
Solved! Go to Solution.
03-28-2016 11:06 AM
You're essentially asking for almost all the data in the database. There is no restriction in NIOS that binds a domain to a single network or a network to a single domain.
My usual question is : Why are you trying to do this ?
What is the report that you want to generate and what does it look like ?
It is feasable that a zone could contain address in all the defined networks. For example, you could have 3 subnets: 10.0.0.0/24, 220.127.116.11/24, 18.104.22.168/24 and with addresses that point to records in 3 different domains:
10.0.0.1 -> gw10.routers.domain.org
10.0.0.20 -> NS1.servers.domain.org
10.0.0.100 -> dhcp10-100.dhcp.domain.org
22.214.171.124 -> gw20.routers.domain.org
126.96.36.199 -> NS2.servers.domain.org
188.8.131.52 -> dhcp20-100.dhcp.domain.org
184.108.40.206 -> gw30.routers.domain.org
220.127.116.11 -> NS3.servers.domain.org
18.104.22.168 -> dhcp30-100.dhcp.domain.org
We don't maintain an index of 'All the networks that point to this domain'
As such you would have to query the IP address of each record for it's network to build up the list.
The 'fastest' way to do this is to write some code that builds up all the networks, but eliminates unnecessary searches. You would do something like this :
- get the first A record from the domain, get it's ip address.
- get the network for this IP address :
my ( $network) = $session->search( object => "Infoblox::DHCP::Network" , contains_address => "10.0.0.1", network_view => $network_view_object, );
- store that network in a list
- get the 'network_container' for that network, store that in another list
- Calculate all the IP addresses for than network,
and identify or eliminate any other DNS records in that domain as having the same network
- get another A record from whatever is left over,
- repeat the network search...
Sorting the DNS record list by ip address makes the elimination process fast, since you just jump to the first record that is outside the network and repeat, walking your way through the DNS records.
Depending on the size of the database, this can be done a lot faster if you just pull ALL the networks and the DNS records once, and then do the processing offline with some sorted arrays.
03-28-2016 11:32 AM
Thank you, Geoff. I was actually following the same steps as you mentioned. I just needed to know if there's any other faster way to do this.
I'm accepting this as the solution.