Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

Highlighted

# Importing reverse zones from MS AD

Posts: 28
5295     0

Hello Guys,

I need to import upto 200 reverse records from AD which have the arpa format: 1.1.10-addr.arpa.net.

But to import these to infoblox I need to convert them to their respective IP/Netmask format like 10.1.1.0/24.

Is there a script to get this done or maybe some other script where I can feed it the notepad file with the arpa records and get the format changed as an output?

Thanks guys!

Highlighted

## Re: Importing reverse zones from MS AD

Community Manager
Posts: 68
5295     0

In what format do you have them? It should be possible with sed/awk or just in excel as a csvto modify.

Highlighted

## Re: Importing reverse zones from MS AD

[ Edited ]
Posts: 28
5296     0

Need to convert the excel colum to 10.1.1.0/24 so I can do the csv import.

Highlighted

## Re: Importing reverse zones from MS AD

Community Manager
Posts: 68
5296     0

2 solutions

• awk
• echo "1.1.10.in-addr.arpa" | awk -F . '{print $3"."$2"."$1".0/24"}' • will return "10.1.1.0/24" • kinda klunky but will do the trick if it is for a few lines without too much variety • Import wizard • www.infoblox.com/import • Much more flexible but the learning curve to deal with the tool ist steaper • Requires you to export the files in the right format from MS • Can generate importable CSV Highlighted ## Re: Importing reverse zones from MS AD Posts: 28 5296 0 I was hoping for a way to use Windows cmd bash script. I have no idea what's awk. I know it's Linux based. Is it available on the infoblox cli itself? Highlighted ## Re: Importing reverse zones from MS AD Community Manager Posts: 68 5296 0 Awk is not unique to linux, you can get it standalone or grab is through gnuwin32 http://gnuwin32.sourceforge.net/ Highlighted ## Re: Importing reverse zones from MS AD Posts: 145 5296 0 Hi, If you are looking for a script that you can run from a Windows machine, you can try the following powershell script. foreach ($a in (Get-Content .\in-addr_arpa_records.txt))
{
$b =$a.Split(".")
Write-Output "$($b[2]).$($b[1]).$($b[0]).0/24" | Out-File .\records_to_networks.txt -Append
}

1.1.10.in-addr.arpa
2.2.10.in-addr.arpa

The script creates an output file "records_to_networks.txt" with content similar to the following

10.1.1.0/24
10.10.1.0/24
10.10.10.0/24
10.2.2.0/24

Hope this helps,

Krishna

Highlighted

## Re: Importing reverse zones from MS AD

Posts: 28
5296     0

Hey,

This looks perfect, will try it out.

Some reverse records are /8 and /16 so I think if I change the output line I can manage that too:

Write-Output "$($b[2]).$($b[1]).0/16"
Write-Output "$($b[1]).0/8"

But I am not sure if this will append to the text file correctly?

Am I doing this right? Should there be an OR statement between the 2 formats of output??

Highlighted

## Re: Importing reverse zones from MS AD

Posts: 145
5296     0

Hello,

You can use the following script:

foreach ($a in (Get-Content .\in-addr_arpa_records.txt)) {$b = $a.Split(".") if($($b[1]) -eq "in-addr") { Write-Output "$($b[0]).0.0.0/8" | Out-File .\records_to_networks.txt -Append } elseif($($b[2]) -eq "in-addr") { Write-Output "$($b[1]).$($b[0]).0.0/16" | Out-File .\records_to_networks.txt -Append } else { Write-Output "$($b[2]).$($b[1]).$(\$b[0]).0/24" | Out-File .\records_to_networks.txt -Append
}
}

If the input file here is

20.in-addr.arpa
10.in-addr.arpa

The output generated will be:

20.0.0.0/8
10.1.1.0/24
10.10.1.0/24
10.10.0.0/16
10.2.2.0/24
10.2.0.0/16
10.0.0.0/8

Hope this helps,

Krishna

Showing results for
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.19498533010482788, "perplexity": 16327.91003235407}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-40/segments/1600401598891.71/warc/CC-MAIN-20200928073028-20200928103028-00667.warc.gz"}