I've read just about every thread in this section and gone through the API reference guide trying to come up with a solution to retrieve all records in a specified zone in the default dns view. I'm using the csv_download function. I have multiple dns views so the query has to specify the default dns view. I am using the RESTful API and using curl on a linux box. I don't have access to installing perl so I can't use the existing examples that require the perl API. Here's what I've pieced together so far. I'm not getting any errors but there is no data being returned.

I'm getting an empty dataset in return. Also, the RESTful API documentation states the following:

"Exports older than a week are removed automatically from the file area. Additional older exports are also removed automatically to keep the size of the WAPI export file directory under 250 megabytes.

This function also supports exporting the CSV file to a named file in a subdirectory called wapi_output in the file distribution area."

How can I look at what is in the wapi_output directory? I don't see any way in the web GUI to see what's on the file system of the gm. I checked the CLI commands and I don't see any way to list files in the wapi_output directory either.

I had planned on downloading the CSV file for each affected zone (renaming each file to the zone name) and using sed/awk to search and replace the old DNS view name to the new DNS view name. Then re-import the zone to the new DNS view. This weekend I'll take a look at the documentation to see how difficult it would be to perform the same functionality without using CSV files. For now I plan on using the CSV file method. The examples you supplied are excellent!

DHosang_1 Don't know if this will help or not but this is what I'm doing:

I log in the the grid master and go to Data Management ---> DNS ---> <click on the dns view you want> ---> Export ---> Export data in Infoblox CSV Import Format

The downloaded CSV file will contain a complete list of all the zones in that DNS view. In the CSV file, keep the column that contains the zone name and throw everything else away. Next, I sort the file and last, I delete the zones I do not want to download CSV files for.

Now I have a sorted list of zone names that I want to download. I posted a BASH shell script on this forum that accepts a list of zones to download. It will download all the zone names listed in the file and renames the CSV file to the name of the zone. I believe my other post is here:

Re: RESTful API call to retrieve all records in a particular dns view/zone

Clark, I've been trying your method but its a bit difficult because of the format I'm trying to get which is

View - Zone - Record - IP Address

Of course you may want to know why this would be helpful but its mainly because we search for IP's containing RFC1918 in External View and it would show what zone and record that should be looked at as an example.

Any help is MOST appreciated on the best way to do this. Infoblox reporting tools are limited on how many records so I have to use some sort of API method to accomplish this.

Re: RESTful API call to retrieve all records in a particular dns view/zone

Are you trying to find all DNS records that are using private IP address space? What I would do is download all the records for every zone in the DNS view. If you put all the csv files in one directory you can run the grep command against all the files and that will give you a list of all private IP address records including which zone file they are in.

This is what I would do:

1) Download a list of all the zones in a particular DNS view.

2) Using that list, download the zone files for each of those zones. The zone file will contain all of the DNS records in that zone.

This grep command will search all the zone files where for the string "10." which would most likely indicate a private IP address. Since the files are CSV files, the IP address would be preceeded with the , delimiter. So the grep command would look for a comma followed by 10. and the rest of the IP address would follow. You could search for 192. also or any of the other private network ranges. Grep appends the name of the file, which will also be the zone name, to the beginning of the line. Sort will sort everything by the zone name. The end result is a text file containing the zone name followed by the DNS record that contains a 10. IP address.

I have all of the scripts to do this. If I did not post them (I can't remember) let me know and I will post them.

Re: RESTful API call to retrieve all records in a particular dns view/zone

I first want to thank you for your help. I would appreciate the scripts since I've been struggling with this for awhile now and I think its because I keep making assumptions on how to do it and it doesn't seem to work. So really scripts for step #2 would be great.

The problem may be that you are passing a variable to the curl command that has a space in it. Here is the next step in troubleshooting. Run the curl command by hand. Don't use variables, type all the info into the command line by hand.

It would probably be best to open a text editor and cut and paste the curl command into the text editor then replace the variables with the actual values you are using. For readability, use the \ character to split the command into multiple lines. After you edit the entire command, cut and paste it into a bash shell window.

Re: RESTful API call to retrieve all records in a particular dns view/zone

OK so I need to edit my bash shell script to handle variables that contain spaces. That is the problem. I'm not going to have time to do that today but I can do it tomorrow. Maybe tonight after work if you need this urgently.

Here are the other scripts I have. Tell me which ones you want:

download-zone-objects.sh

This script gets a list of all the zones in a DNS view. It only contains the csv data to recreate the empty zones. It does not contain the actual DNS records inside each zone.

batch-download-zone-records.sh

The script accepts the name of a file that contains a list of zones. The script will download all the records in each zone that are listed in the file.

Once you get this far, you will have a bunch of csv files containing zone records. You can edit these records and re-upload (import) them. I have some scripts that pre-process this zone data. One thing it does is change the DNS view for the records. That way when I batch upload them, they go into the new DNS view. I'm not going to include those scripts becuase they perform functions specific to my situation. However, I can sanitize some of the scripts to remove my into so you can see how the files can be precessed.

upload-csv.sh

This script will upload a SINGLE csv file to the infoblox grid master for importing

batch-upload-zone-records.sh

Uploads and imports ALL of the csv files in a specified directory. The zones have to exist already. The csv files contain the records in the zones. The csv files are named the same as the zone name.

Re: RESTful API call to retrieve all records in a particular dns view/zone

Nope, the problem is the spaces in your the name of your DNS view. When you have those spaces in there, curl thinks it's the end of that parameter. I have to have the BASH shell script escape the spaces.

The nice thing about scripting this is that you can download the csv file containing all the zone names. You can then use the shell command "cut" to easily parse out the zone names and pipe them to a file. Then you can use that file with the script batch-download-zone--records.sh and you will get a bunch of csv files named after the zones. These files contain all the records for that zone.

You can run other scripts to modify the data. I have a script - a bash one liner - that changes the DNS view name. That way when I batch upload the csv files, they all go into the new DNS view. You can copy records from one view to another in the GUI but if you have 75 zones to copy it starts to get "not practical"

And besides, you will go insane clicking on the same sequence of buttons for every copy option. Maybe fall into a trance. It's too bad Infoblox doesn't have a batch copy to move data from one view to another. These scripts solve that.

OK I will work on fixing that shell script so it will account for spaces in a variable name. I need to go through my scripts before I upload them to make sure I removed any company info.

Re: RESTful API call to retrieve all records in a particular dns view/zone

It's almost midnight and I'm just looking into this now. Curl coes not like having spaces in the URL so I was right about that part. Your DNS view has spaces in the name and that name is part of the URL. What I need to do is modify my script to check the "DNS View" variable and replace any spaces with %20

Not sure how I'm going to format that as I don't know how bash will interpret the % symbol. I'll have to create a dummy DNS View in my lab environment and give it a name with spaces in it. I can test this on Friday. I think I can have this fixed quickly. I will update tomorrow.

Re: RESTful API call to retrieve all records in a particular dns view/zone

I tried some things in the lab with no luck. I created a DNS View with spaces in the name and used my script to download some zone records. I verified that a zone name with no spaces works. Also verified a zone name with spaces did not work.

I tried escaping the spaces in the zone name. That didn't work. Also tried replacing the spaces with %20 and that didn't work. Finally I tried quoting the DNS View variable with double and single quotes and that didn't work.

I'm sure this can be done, I just haven't figured out how to do it yet. I will google search for examples of using curl with a URL that contains spaces. Still researching.

Re: RESTful API call to retrieve all records in a particular dns view/zone

Wow! really gave it a good effort. I really appreciate it. I ended up changing the DNS View so it doesn't contain spaces and it appears the script works up to the point its suppose to close the connection then it gives the silly error

What's really strange is that it was able to resolve it just fine earlier in the script but now it can't at the end. Puzzling. I'll keep poking at it.

I looked at a domain.com.csv and it shows this:

<HTML><HEAD><TITLE>Network Error</TITLE></HEAD><BODY><FONT face="Helvetica"><big><strong></strong></big><BR></FONT><blockquote><TABLE border=0 cellPadding=1 width="80%"><TR><TD><FONT face="Helvetica"><big>Network Error (ssl_domain_invalid)</big><BR><BR></FONT></TD></TR><TR><TD><FONT face="Helvetica">Your request contacted a host which presented a certificate with a Common Name that did not match the domain requested.</FONT></TD></TR><TR><TD><FONT face="Helvetica">This is typically caused by a Web Site presenting an incorrect or invalid certificate, but could be because of a configuration error.</FONT></TD></TR><TR><TD><FONT face="Helvetica" SIZE=2><BR>

</FONT></TD></TR></TABLE></blockquote></FONT></BODY></HTML>

Odd since I don't get any errors through the GUI and even with the new Chrome 58 it passes so we know the SAN is good.