Reply

List all Zones and Lock Free IP

Techie
Posts: 16
16388     0
Hello All, Would like to know is there ant RESTAPI call which can 1) Show/list all the zones at once. I know through CLI i can run 'show config dns' and check for all zones. But i want to know is there any way to do through API? There is one API call to list 'allrecords' that is for a particular zone 2) I can see there is a RESTAPI to get free IP of a network but is there any way to lock the IP that we got? QIP does that can't find it here

Re: List all Zones and Lock Free IP

Authority
Posts: 5
16389     0

#1 can be done through either downloading the named.conf from an appliance, which should be the same as what show config dns outputs from that same appliance, or querying for the zones through the API.  I wrote a script to dump the equivalent of the db files and first download the named.conf and parse it to use the zones to do a zone transfer for the rest of the data.  You may want to elaborate what you are doing in order to get a more precise answer.

#2 When we migrated from QIP to Infoblox a couple of years ago Infoblox added the functionality to address this issue of the QIP lock.  They don't have a lock, but they allow you to add a host record on the next available IP, which is what we were actually using the lock for in our QIP script.  Here is an example using curl ot do that, this requires v1.2.1 of wapi:

curl -s -k -u usernameSmiley Tongueassword -H "Content-Type: application/json" -d '{"name": "hostname.domain.com", "ipv4addrs":[{ "ipv4addr": "func:nextavailableip:10.0.0.0/24" }]}' -X POST https://gridmaster.domain.com/wapi/v1.2.1/record:host

 

Hi Craig and All,

Techie
Posts: 16
16389     0
Hi Craig and All, Thanks Craig for responding. So we are trying to build app for ourselves and may be customers for all those people who are using InfoBlox which would fetch all zones details and display all records. For this the API that i see in infoblox wapi document going fetch for a particular zone. "#1 can be done through either downloading the named.conf from an appliance, which should be the same as what show config dns outputs from that same appliance, or querying for the zones through the API. I wrote a script to dump the equivalent of the db files and first download the named.conf and parse it to use the zones to do a zone transfer for the rest of the data." ----->You suggested queryng all zones but before i query i would need list of all zones how can i get that. Is there any API call for that.However writing a script to dump db files and parsing named.conf and doing zone transfer is good option but how much feasible i would check. Thanks for this #2 When we migrated from QIP to Infoblox a couple of years ago Infoblox added the functionality to address this issue of the QIP lock. They don't have a lock, but they allow you to add a host record on the next available IP, which is what we were actually using the lock for in our QIP script. Here is an example using curl to do that, this requires v1.2.1 of wapi: ----->This definately helps. However i have one more question As per InfoBlox version 7 WAPI document i dont see anywhere curl required can't i directly perform GET/PUT/POST/DELETE REST api call over HTTPS without any curl etc installed. Thanks again

Listing all zones

Adviser
Posts: 33
16389     0

"before i query i would need list of all zones how can i get that" To get a list of all forward- and reverse-mapping zones in the default DNS view you can send an HTTPS GET request with the URL

https://gm.example.com/wapi/v2.0/zone_auth

Replace "gm.example.com" with the name of your grid master and "2.0" with the Web API version number for your version of NIOS (2.0 is for NIOS 7.0). This call will return a list of zone objects; each zone object contains (among other things) the field "fqdn", whose value is either the fully-qualified domain name for a forward mapping zone (e.g., "example.com") or the network address in CIDR format for a reverse mapping zone (e.g., "192.168.1.0/24").

If you need to retrieve the zones in a non-default DNS view then you can add an additional search criterion to the URL:

https://gm.example.com/wapi/v2.0/zone_auth?view=external

Once you have the list of zones you can retrieve records in each zone using the allrecords object, as you note;for example, an HTTPS GET request with the following URL will return all records in the zone "example.com" in the "external" DNS view:

https://gm.example.com/wapi/v2.0/allrecords?zone=example.com&view=external

However this just returns the name and type of the records; in actual practice you'll want to return additionalfields as well, for example

https://gm.lab.fhecker.com/wapi/v2.0/allrecords?zone=lab.fhecker.com&view=internal&_return_fields=na...

For record types other than A or AAAA (for which the "address" field holds the value) you'll need to unpack the"record" field to extract the record values.

"can't i directly perform GET/PUT/POST/DELETE REST api call over HTTPS without any curl etc installed." You can use any programming language you want to use. On these forums we typically use curl to show API examples because it's easy to try out the examples from the command line and doesn't require us to write Python or other code.

Thank you so much Frank this

Techie
Posts: 16
16389     0
Thank you so much Frank this is what exactly i was looking for. I was doing the same thing but i was using some reference "zone_auth/ZG5zLmhvc3QkLl9kZWZhd3QuaDE" . I have no ideas about API and i am fetting chance to work with it first time the document is bit confusing But Frank thank you again.

However i have another

Techie
Posts: 16
16389     0
However i have another question Frank. The API method calls that you send are for specific network view which you have named as 'internal' and 'external'. But ideally if i want to get list of all the zones ideally shouldn't i be running this command for all the network view or is it DNS record can be associated to only one single network view?

Returning list of network views and DNS views

Adviser
Posts: 33
16389     0

My apologies, I gave you incorrect information. If you do a WAPI GET request for a URL like

https://gm.example.com/wapi/v2.0/zone_auth

it will in fact return a list of all zones, no matter what DNS view or network view they are in.

Recall that network views are at the highest level of the hierarchy: You can have multiple network views, each network view can contain multiple DNS views, and each DNS view (within a network view) can contain multiple zones. If you have only one network view and multiple DNS views within that network view then you can retrieve zones within a particular view by giving the DNS view name as part of the URL, for example:

https://gm.example.com/wapi/v2.0/zone_auth?view=external

for a DNS view named "external" and

https://gm.example.com/wapi/v2.0/zone_auth?view=default

for the default DNS view. (This assumes you haven't given the default DNS view a different name.)

If you have multiple network views then you have to specify the network view name as part of the URL as well. For example,

https://gm.example.com/wapi/v2.0/zone_auth?view=external.nv1

for zones in the DNS view "external" in the network view "nv1", or

https://gm.example.com/wapi/v2.0/zone_auth?view=external.nv1

for zones in the DNS view "external" in the default network view.

If you want a list of all the defined network views you can do a WAPI GET request with the following URL:

https://gm.example.com/wapi/v2.0/networkview

If you want a list of all the defined DNS views within a specified network view you can do a WAPI GET request with the following URL:

https://gm.example.com/wapi/v2.0/view?network_view=nv1

Thank you so much Frank. This

Techie
Posts: 16
16389     0
Thank you so much Frank. This is what i was looking for . Also now i am testing another API to add/delete/modify A,PTR,CNAME etc records. As per this link https://community.infoblox.com/blogs/2013/03/25/create-search-and-delete-host-object-using-rest-api i tried but didnt get any success. This is what i tried POST https://Grid_master-IP/wapi/v2.0/record:a Body: { "ipv4addr": "192.x.y.z", "name": "abc.testdomain.com", "view": "default" } Error: { "Error": "AdmConProtoError: Unknown Content-Type: text/plain", "code": "Client.Ibap.Proto.UnknownContentType", "text": "Unknown Content-Type: text/plain" } Also i tried one more thing Should i create another thread for thing: POST https://Grid-Master_IP.70/wapi/v2.0/record:a/ZG5zLnpvbmUkLl9kZWZhdWx0Lm5ldC5hdnhsYWIuem9uZTEx:zone11... Body: { "ipv4addr": "192.x.y.z", "name": "abc", "view": "default" } I still get same error { "Error": "AdmConProtoError: Unknown Content-Type: text/plain", "code": "Client.Ibap.Proto.UnknownContentType", "text": "Unknown Content-Type: text/plain" }

Use application/json header when doing WAPI POST operation

Adviser
Posts: 33
16389     0

My apologies for the delay in responding. When you use a POST or PUT request to do a NIOS WAPI add or modify operation you need to include a Content-Type header specifying that the posted data is in JSON format. Recall that in the original example you linked to the curl command for the POST request had the option -H "Content-Type: application/json" to supply the necessary HTTP header. If you are programming in Python or Perl then you need to add some extra code to send the Content-Type header.

I'll start a separate thread and provide some curl and Python examples for adding, modifying, and deleting an A record.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You