-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZoneCreator.pl
138 lines (129 loc) · 5.39 KB
/
ZoneCreator.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
https://github.com/kylebuckingham/Perl_Zone_Creator.git
#!/opt/csw/bin/perl
# Purpose: web based tool for host and ip dns queries.
use strict;
use CGI;
use CGI::Pretty;
use CGI::Carp('fatalsToBrowser');
use POSIX qw/strftime/;
my $serial = strftime("%Y%m%d", localtime(time));
$serial .= "01";
my $dig = "/usr/sbin/dig";
my $q = CGI->new;
my $self = $q->url;
print $q->header;
print $q->start_html( -title => "online zone creator", );
print qq(<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>\n);
print $q->h2("DNS Zone File Creator");
print $q->start_form(-name => "loop");
print $q->p("Enter your user email");
print $q->textfield(-name => "username",
-size => "30",
-default =>'username.example.com');
print $q->p("Enter the domain or subdomain which you would like to add:");
print $q->textfield(-name => "zone",
-size => "30",
-default =>'www.example.com');
print $q->p("Serial version of the file (usually a date):");
print $q->textfield(-name => "serial",
-size => "30",
-default =>"$serial");
print $q->p("Refresh time:");
print $q->textfield(-name => "refresh",
-size => "10",
-default =>'3600');
print $q->p("Retry time:");
print $q->textfield(-name => "retry",
-size => "10",
-default =>'3600');
print $q->p("Expire time:");
print $q->textfield(-name => "expire",
-size => "10",
-default =>'3600');
print $q->p("Minimum negative TTL:");
print $q->textfield(-name => "TTL",
-size => "10",
-default =>'7200');
print $q->p("Select the type of record which you would like to add:");
print "<div class='duplicateme' style='display:block;'>";
print "<tr>";
print "<td style='padding: 20px 10px 10px 10px;'>";
print $q->p("Record type");
print $q->p($q->popup_menu(-name => 'zonetype', -id => 'form1',
-'values' =>['A','AAAA','CNAME','MX','NS'],
-default =>'A'));
print "</td>";
print "<td>";
print $q->p("Enter the record name");
print $q->textfield(-name => "recordID", -id => 'form2',
-size => "30",
-default =>'www.example.com');
print "</td>";
print "<td>";
print $q->p("Enter the corresponding record name (in name) or IP Address");
print $q->textfield(-name => "recordIDin", -id => 'form3',
-size => "30",
-default =>'192.168.0.1');
print "</td>";
print "</tr>";
print "</table>";
print "</div>";
print $q->br;
print $q->button({-id=>"addrecord", -value=>"Add Record"});
print $q->submit({-class=>"submit", -name=>"loop", -value=>"Create My Zone File!"});
print $q->hr;
print $q->h2("Here is your zone file for: ". $q->param('zone'));
print <<EOD;
<table>
<tr>
<td>
<pre>
EOD
my $username = $q->param('username');
$username =~ s/@/./;
my $zone = $q->param('zone');
my $serial = $q->param('serial');
my $refresh = $q->param('refresh');
my $retry = $q->param('retry');
my $expire = $q->param('expire');
my $TTL = $q->param('TTL');
print "\$ORIGIN\ $zone. ; default zone, note trailing dot\n";
print "\$TTL\ $TTL ; default time to live set to one hour\n";
print "@ IN SOA $zone. $username. (\n";
print " $serial ; serial version of the file (usually a date)\n";
print " $refresh ; refresh, slaves refresh after one hour\n";
print " $retry ; retry after one hour\n";
print " $expire ; Expire after one day\n";
print " );\n";
print " \n";
if($q->param('loop')) {
my @recordID = $q->param("recordID");
my @recordIDin = $q->param("recordIDin");
my @zonetype = $q->param('zonetype');
for(my $i=0; $i<=$#recordID; $i++) {
if ( $zonetype[$i] eq 'A' ) {
print "$recordID[$i]. IN A $recordIDin[$i] ; Authoritative IPv4 Record\n",
}
if ( $zonetype[$i] eq 'AAAA' ){
print "$recordID[$i]. AAAA $recordIDin[$i] ; IPv6 Address Record\n",
}
if ( $zonetype[$i] eq 'CNAME' ){
print "$recordID[$i]. IN CNAME $recordIDin[$i] ; Cononical alias\n",
}
if ( $zonetype[$i] eq 'MX' ){
print "$recordID[$i]. MX $recordIDin[$i] ; Mailserver Record\n",
}
if ( $zonetype[$i] eq 'NS' ){
print "$recordID[$i]. NS $recordIDin[$i] ; NS (Name Server) records\n",
}
}
}
print <<EOD;
</pre>
</td>
</tr>
</table>
EOD
print qq(<script type="text/javascript" src="http://www.tradetech.net/javascript.js"></script>\n);
print $q->end_form;
print $q->end_html;