Reply
Highlighted
Accepted Solution

Importing reverse zones from MS AD

Authority
Posts: 15
1124     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!

Re: Importing reverse zones from MS AD

Ingmar Community Manager
Community Manager
Posts: 28
1125     0

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

Re: Importing reverse zones from MS AD

[ Edited ]
Authority
Posts: 15
1125     0

They are in the arpa addr format - 1.1.10.in-addr.arpa 

 

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

Re: Importing reverse zones from MS AD

Ingmar Community Manager
Community Manager
Posts: 28
1125     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

Re: Importing reverse zones from MS AD

Authority
Posts: 15
1125     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?

Re: Importing reverse zones from MS AD

Ingmar Community Manager
Community Manager
Posts: 28
1125     0

Awk is not unique to linux, you can get it standalone or grab is through gnuwin32

http://gnuwin32.sourceforge.net/

Re: Importing reverse zones from MS AD

Adviser
Posts: 60
1125     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
}

This assumes that your addresses are stored in the 1.1.10.in-addr.arpa format in the file "in-addr_arpa_records.txt", similar to the content below

1.1.10.in-addr.arpa
1.10.10.in-addr.arpa
10.10.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

Re: Importing reverse zones from MS AD

Authority
Posts: 15
1125     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??

Re: Importing reverse zones from MS AD

Adviser
Posts: 60
1125     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
1.1.10.in-addr.arpa
1.10.10.in-addr.arpa
10.10.in-addr.arpa
2.2.10.in-addr.arpa
2.10.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 
Search instead for 
Do you mean 

Recommended for You