Generate zone files based off subnet


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Generate zone files based off subnet
# 1  
Old 08-16-2012
Generate zone files based off subnet

Hi, I'm attempting to generate zone files based off the subnet address of a reverse zone.

For example...
My text file contains the following..

5.4.7.0/24
5.4.7.0/24
68.74.23.0/24
68.74.24.0/24

I want to create a separate file for each of the listed blocks. Each file should contain placeholder reverse records as well as the zone configuration information at the top of the file. The file should also be named after the reverse block.

Example file should be the following... (putting {tab} to represent tabs.)

5.4.7.0\24 should become...

7.4.5.in-adddr.arpa (file name)
@{tab}{tab}NS{tab}ns1.servername.net.
@{tab}{tab}NS{tab}ns2.servername.net.
@{tab}{tab}NS{tab}ns3.servername.net.
@{tab}{tab}NS{tab}ns4.servername.net.
@{tab}{tab}NS{tab}ns5.servername.net.
1{tab}3600{tab}PTR{tab}5-4-7-1-reversezone.home.net
2{tab}3600{tab}PTR{tab}5-4-7-2-reversezone.home.net
3{tab}3600{tab}PTR{tab}5-4-7-3-reversezone.home.net
4{tab}3600{tab}PTR{tab}5-4-7-4-reversezone.home.net
5{tab}3600{tab}PTR{tab}5-4-7-5-reversezone.home.net
6{tab}3600{tab}PTR{tab}5-4-7-6-reversezone.home.net


I need to do this for about 2000 zones. Each zone file should go from 1 all the way down to 255. Any assistance would be greatly appreciated.
# 2  
Old 08-16-2012
Quote:
Originally Posted by spartan22
Hi, I'm attempting to generate zone files based off the subnet address of a reverse zone.

For example...
My text file contains the following..

5.4.7.0/24
5.4.7.0/24
68.74.23.0/24
68.74.24.0/24

I want to create a separate file for each of the listed blocks. Each file should contain placeholder reverse records as well as the zone configuration information at the top of the file. The file should also be named after the reverse block.

Example file should be the following... (putting {tab} to represent tabs.)

5.4.7.0\24 should become...

7.4.5.in-adddr.arpa (file name)
@{tab}{tab}NS{tab}ns1.servername.net.
@{tab}{tab}NS{tab}ns2.servername.net
@{tab}{tab}NS{tab}ns3.servername.net.
@{tab}{tab}NS{tab}ns4.servername.net.
@{tab}{tab}NS{tab}ns5.servername.net.
1{tab}3600{tab}PTR{tab}5-4-7-1-reversezone.home.net
2{tab}3600{tab}PTR{tab}5-4-7-2-reversezone.home.net
3{tab}3600{tab}PTR{tab}5-4-7-3-reversezone.home.net
4{tab}3600{tab}PTR{tab}5-4-7-4-reversezone.home.net
5{tab}3600{tab}PTR{tab}5-4-7-5-reversezone.home.net
6{tab}3600{tab}PTR{tab}5-4-7-6-reversezone.home.net


I need to do this for about 2000 zones. Each zone file should go from 1 all the way down to 255. Any assistance would be greatly appreciated.
You say your input file contains:
Code:
5.4.7.0/24
5.4.7.0/24
68.74.23.0/24
68.74.24.0/24

Note that the first two lines are identical. Later you say:
Quote:
5.4.7.0\24 should become...
Which shows a <backslash> character while your input file shows a <slash> character. Which is it? Or is everything starting with the third <period> on each input line supposed to be completely ignored?

In your example, you have a line:
Quote:
7.4.5.in-adddr.arpa (file name)
Is this line without the " (file name)" supposed to appear in the file as well as be the name of the file containing the following data?

Are all 2000 zones to be changed in your input file, or will the input files be a lot shorter? (I.e., if I use awk for this will I need to consider file descriptor management?) Since the first two lines in your input are identical, should the second request to create that reverse zone file overwrite the first one, or append to it? Or does the script have to detect that the file already exists and give an error message instead of replacing or appending to the current file?

Other than creating the output files and writing the requested data into them, do you want the script to write anything to standard output when each input line is processed?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In PErl script: need to read the data one file and generate multiple files based on the data

We have the data looks like below in a log file. I want to generat files based on the string between two hash(#) symbol like below Source: #ext1#test1.tale2 drop #ext1#test11.tale21 drop #ext1#test123.tale21 drop #ext2#test1.tale21 drop #ext2#test12.tale21 drop #ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies

2. Shell Programming and Scripting

Generate Join clause based on key data

Hi, I have a file pk.txt which has pk data in following format TableName | PK Employee | id Contact|name,country My Output should be Employee | t1.id=s.id Contact| t1.name=s.name AND t1.country=s.country I started of like this: for LIST in `cat pk.txt` do... (5 Replies)
Discussion started by: wahi80
5 Replies

3. Shell Programming and Scripting

Generate a DML dynamically based off of header record

I have the following scenario where I need to use a header record from a file and generate a DML based off of it... E.g.: The header can change periodically with an additional column in between or remove a col.... Sample header : (head -1 sample.txt)... (17 Replies)
Discussion started by: anduzzi
17 Replies

4. Shell Programming and Scripting

Generate files from one file based on lines

Hi Friends, I have a file1 file1.txt 1ABC 13478 aqjerh 473 343 2hej 478 5775 24578 23892 3fhd fg 847 brjkb f99345 487 4eh ehjk 84 47589 8947 234 5784 487 738 52895 8975 6 57489 eghe9 4575 859479 7fnbd 4y5 4iuy 458 h irh 8fjdg 74 7845 8475 5789 94yr 48yr 4hr erhj reh... (3 Replies)
Discussion started by: i150371485
3 Replies

5. Shell Programming and Scripting

How to generate a csv files by separating the values from the input file based on position?

Hi All, I need help for doing the following. I have a input file like: aaaaaaaaaabbbbbbbbbbbbbbbbbbbb cccbbbbbaaaaaadddddaaaabbbbbbb now I am trying to generate a output csv file where i will have for e.g. 0-3 chars of each line as the first column in the csv, 4-10 chars of the line as... (3 Replies)
Discussion started by: babom
3 Replies

6. Solaris

Zone subnet change

Hello, I'm in the process of changing the netmask on my servers from /24 to /23. I have been doing this on the Solaris 9 and the global zones on Solaris 10 servers. sudo vi /etc/netmasks sudo ifconfig <device> IP/23 The question is this, should I do it this way in the zone or should I do it... (4 Replies)
Discussion started by: bitlord
4 Replies

7. Shell Programming and Scripting

generate report based on data in files.

Hi All, I need to develop a shell script which does sanity check of a data file, as below. 1. For DATE columns, it should check if date is given in proper format or not? For example, if format of date is expected as DD-MON-YYYY HH24:MI:SS and we received the date in formation like DDMMYYYY HH24,... (1 Reply)
Discussion started by: ace_friends22
1 Replies

8. IP Networking

Network mapper based on zone files ?

Good morning, Say I have a zone file like this: ns.chicago.company.com. 86400 IN A 212.168.12.15 ns.casper.company.com. 86400 IN A 212.168.14.15 company.com. 86400 IN NS ns.aux.company.com. ns.aux.company.com. 86400 IN ... (2 Replies)
Discussion started by: BigBro
2 Replies

9. IP Networking

Migrating existing Subnet to a new subnet and changing ip addresses in UNIX

Hi, My project needs to migrate the existing Subnet (255.255.255.0) to a new subnet and change the ipaddresses (currently C class). How can I do that. I need some information. John (0 Replies)
Discussion started by: johnmarsh
0 Replies
Login or Register to Ask a Question