3 require './dns-lib.pl';
5 &header("BIND 4 DNS Server", "", undef, 1, 1);
7 %access = &get_module_acl();
9 # Check if named exists
10 if (!-x $config{'named_pathname'}) {
11 print "<p>The BIND 4 DNS server <i>$config{'named_pathname'}</i>\n";
12 print "could not be found on your system. Maybe it is not installed,\n";
13 print "or your <a href=\"$gconfig{'webprefix'}/config.cgi?$module_name\">BIND 4 module\n";
14 print "configuration</a> is incorrect. <p>\n";
16 &footer("/", "index");
20 # Check for future versions of BIND with the -v option
21 $out = `$config{'named_pathname'} -v 2>&1`;
22 if (0 && ($out =~ /bind\s+(\d+)\./i || $out =~ /named\s+(\d+)\./) && $1 >= 8) {
23 print "<p>The server <i>$config{'named_pathname'}</i> appears to\n";
24 print "be BIND 8. Maybe your should use the\n";
25 print "<a href=/bind8/>BIND 8 server module</a> instead. <p>\n";
27 &footer("/", "index");
31 # Check if BIND is the right version.. Only BIND 8 offers the -f option
32 # Is there a better way to do this?
33 $out = `$config{'named_pathname'} -help 2>&1`;
34 if (0 && $out =~ /\[-f\]/) {
35 print "<p>The server <i>$config{'named_pathname'}</i> appears to\n";
36 print "be BIND 8. Maybe your should use the\n";
37 print "<a href=/bind8/>BIND 8 server module</a> instead. <p>\n";
39 &footer("/", "index");
43 # If the named.boot file is empty or does not exist, offer to create it
44 if (!-r $config{named_boot_file}) { $need_create++; }
46 $conf = &get_config();
47 if (!@$conf) { $need_create++; }
51 # There is no nameserver boot file.. offer to create
52 print "<p>The primary configuration file\n";
53 print "<i>$config{named_boot_file}</i> does not exist,\n";
54 print "or is empty. Create it?<p>\n";
55 print "<form action=\"dns_boot.cgi\">\n";
56 print "<input type=radio name=real value=0> Setup nameserver for ",
57 "internal non-internet use only<p>\n";
58 print "<input type=radio name=real value=1 checked> Setup as an ",
59 "internet name server, and download root server information<p>\n";
60 print "<input type=radio name=real value=2> Setup as an internet name ",
61 "server, but use Webmin's older root server information<p>\n";
62 print "<center><input type=submit value=\"Create Primary Configuration File and Start Nameserver\"></center>\n";
65 &footer("/", "index");
69 @zlist = (&find_config("primary", $conf), &find_config("secondary", $conf));
71 # Nothing in named file..
72 print "<b>There are no DNS zones defined for this name server</b><p>\n";
75 print &ui_subheading("Existing DNS Zones");
77 next if (!&can_edit_zone(\%access, $z->{'values'}->[0]));
78 if ($z->{'name'} eq "primary") {
79 push(@zlinks, "edit_master.cgi?index=$z->{'index'}");
80 push(@ztitles, &arpa_to_ip($z->{'values'}->[0]));
81 push(@zicons, "../bind8/images/master.gif");
82 push(@ztypes, "Master");
85 push(@zlinks, "edit_slave.cgi?index=$z->{'index'}");
86 push(@ztitles, &arpa_to_ip($z->{'values'}->[0]));
87 push(@zicons, "../bind8/images/slave.gif");
88 push(@ztypes, "Slave");
94 @zorder = sort { $ztitles[$a] cmp $ztitles[$b] } (0 .. $len-1);
95 @zlinks = map { $zlinks[$_] } @zorder;
96 @ztitles = map { $ztitles[$_] } @zorder;
97 @zicons = map { $zicons[$_] } @zorder;
98 @ztypes = map { $ztypes[$_] } @zorder;
100 if ($config{'show_list'}) {
102 $mid = int((@zlinks+1)/2);
103 print "<table width=100%><tr><td width=50% valign=top>\n";
104 &zones_table([ @zlinks[0 .. $mid-1] ],
105 [ @ztitles[0 .. $mid-1] ],
106 [ @ztypes[0 .. $mid-1] ]);
107 print "</td><td width=50% valign=top>\n";
108 if ($mid < @zlinks) {
109 &zones_table([ @zlinks[$mid .. $#zlinks] ],
110 [ @ztitles[$mid .. $#ztitles] ],
111 [ @ztypes[$mid .. $#ztypes] ]);
113 print "</td></tr></table>\n";
117 &icons_table(\@zlinks, \@ztitles, \@zicons);
120 if ($access{'master'}) {
121 print "<a href=\"master_form.cgi\">Create a new ",
122 "master zone</a> \n";
124 if ($access{'slave'}) {
125 print "<a href=\"slave_form.cgi\">Create a new ",
126 "slave zone</a> \n";
130 if ($access{'defaults'}) {
131 # Display form to set the defaults for new zones
132 &get_zone_defaults(\%zd);
134 print &ui_subheading("New Master Zone Defaults");
135 print "<form action=save_zonedef.cgi>\n";
136 print "<table border>\n";
137 print "<tr $tb> <td><b>Defaults for new master zones</b></td> </tr>\n";
138 print "<tr $cb> <td><table cellpadding=5>\n";
140 print "<tr> <td><b>Refresh time</b></td>\n";
141 print "<td><input name=refresh size=10 value=$zd{'refresh'}> seconds</td>\n";
142 print "<td><b>Transfer retry time</b></td>\n";
143 print "<td><input name=retry size=10 value=$zd{'retry'}> seconds</td></tr>\n";
145 print "<tr> <td><b>Expiry time</b></td>\n";
146 print "<td><input name=expiry size=10 value=$zd{'expiry'}> seconds</td>\n";
147 print "<td><b>Default time-to-live</b></td>\n";
148 print "<td><input name=minimum size=10 value=$zd{'minimum'}> seconds</td>\n";
149 print "</tr> </table></td></tr></table><br>\n";
150 print "<input type=submit value=Update></form>\n";
153 # Display a form to start or restart named
155 if ($config{'named_pid_file'}) {
156 if (open(PID, $config{'named_pid_file'})) {
163 &foreign_require("proc", "proc-lib.pl");
164 foreach $p (&proc::list_processes()) {
165 if ($p->{'args'} =~ /^\Q$config{'named_pathname'}\E/) {
171 if ($pid && kill(0, $pid)) {
173 print "<form action=restart.cgi>\n";
174 print "<input type=hidden name=pid value=$pid>\n";
175 print "<table width=100%><tr><td>\n";
176 print "<input type=submit value=\"Apply Changes\"></td>\n";
177 print "<td>Click this button to restart the running BIND 4 server.\n";
178 print "This will cause the current configuration to become\n";
179 print "active</td> </tr></table>\n";
183 # named is not running
184 print "<form action=start.cgi>\n";
185 print "<table width=100%><tr><td>\n";
186 print "<input type=submit value=\"Start Name Server\"></td>\n";
187 print "<td>Click this button to start the BIND 4 server, and load\n";
188 print "the current configuration</td> </tr></table>\n";
193 &footer("/", "index");
198 print "<table border width=100%>\n";
199 print "<tr $tb> <td><b>Zone</b></td> <td><b>Type</b></td> </tr>\n";
200 for($i=0; $i<@{$_[0]}; $i++) {
202 print "<td><a href=\"$_[0]->[$i]\">$_[1]->[$i]</a></td>\n";
203 print "<td>$_[2]->[$i]</td>\n";