Project

General

Profile

Download (12.4 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_dnsmasq.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 f0fe3d30 Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Bob Zoller <bob@kludgebox.com> and Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 f0fe3d30 Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 f0fe3d30 Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 f0fe3d30 Scott Ullrich
16 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19 f0fe3d30 Scott Ullrich
20 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32 6b07c15a Matthew Grooms
##|+PRIV
33
##|*IDENT=page-services-dnsforwarder
34
##|*NAME=Services: DNS Forwarder page
35
##|*DESCR=Allow access to the 'Services: DNS Forwarder' page.
36
##|*MATCH=services_dnsmasq.php*
37
##|-PRIV
38
39
40 5b237745 Scott Ullrich
require("guiconfig.inc");
41
42 4d6ba181 Scott Ullrich
$pconfig['enable']  = isset($config['dnsmasq']['enable']);
43 5b237745 Scott Ullrich
$pconfig['regdhcp'] = isset($config['dnsmasq']['regdhcp']);
44 6a01ea44 Bill Marquette
$pconfig['regdhcpstatic'] = isset($config['dnsmasq']['regdhcpstatic']);
45 5b237745 Scott Ullrich
46 4d6ba181 Scott Ullrich
if (!is_array($config['dnsmasq']['hosts'])) 
47 5b237745 Scott Ullrich
	$config['dnsmasq']['hosts'] = array();
48 0c2b5df7 Scott Ullrich
49 4d6ba181 Scott Ullrich
if (!is_array($config['dnsmasq']['domainoverrides'])) 
50 0c2b5df7 Scott Ullrich
       $config['dnsmasq']['domainoverrides'] = array();
51
52 4d6ba181 Scott Ullrich
53
$a_hosts 	   = &$config['dnsmasq']['hosts'];
54 0c2b5df7 Scott Ullrich
$a_domainOverrides = &$config['dnsmasq']['domainoverrides'];
55 5b237745 Scott Ullrich
56
if ($_POST) {
57
58
	$pconfig = $_POST;
59
60
	$config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false;
61
	$config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false;
62 6a01ea44 Bill Marquette
	$config['dnsmasq']['regdhcpstatic'] = ($_POST['regdhcpstatic']) ? true : false;
63 5b237745 Scott Ullrich
64
	write_config();
65 f0fe3d30 Scott Ullrich
66 5b237745 Scott Ullrich
	$retval = 0;
67 920b3bb0 Scott Ullrich
	$retval = services_dnsmasq_configure();
68 5b237745 Scott Ullrich
	$savemsg = get_std_save_message($retval);
69
70 a368a026 Ermal Lu?i
	if ($retval == 0)
71
		clear_subsystem_dirty('hosts');
72 5b237745 Scott Ullrich
}
73
74
if ($_GET['act'] == "del") {
75 0c2b5df7 Scott Ullrich
       if ($_GET['type'] == 'host') {
76
               if ($a_hosts[$_GET['id']]) {
77
                       unset($a_hosts[$_GET['id']]);
78
                       write_config();
79 a368a026 Ermal Lu?i
			mark_subsystem_dirty('hosts');
80 0c2b5df7 Scott Ullrich
                       header("Location: services_dnsmasq.php");
81
                       exit;
82
               }
83
       }
84
       elseif ($_GET['type'] == 'doverride') {
85
               if ($a_domainOverrides[$_GET['id']]) {
86
                       unset($a_domainOverrides[$_GET['id']]);
87
                       write_config();
88 a368a026 Ermal Lu?i
			mark_subsystem_dirty('hosts');
89 0c2b5df7 Scott Ullrich
                       header("Location: services_dnsmasq.php");
90
                       exit;
91
               }
92
       }
93 5b237745 Scott Ullrich
}
94 0c2b5df7 Scott Ullrich
95 d88c6a9f Scott Ullrich
$pgtitle = array("Services","DNS forwarder");
96 b63695db Scott Ullrich
include("head.inc");
97 0c2b5df7 Scott Ullrich
98 5b237745 Scott Ullrich
?>
99
100 6a01ea44 Bill Marquette
<script language="JavaScript">
101
<!--
102
function enable_change(enable_over) {
103
	var endis;
104
	endis = !(document.iform.enable.checked || enable_over);
105
	document.iform.regdhcp.disabled = endis;
106
	document.iform.regdhcpstatic.disabled = endis;
107
}
108
//-->
109
</script>
110
111 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
112
<?php include("fbegin.inc"); ?>
113 6a01ea44 Bill Marquette
<form action="services_dnsmasq.php" method="post" name="iform" id="iform">
114 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
115 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('hosts')): ?><p>
116 5b237745 Scott Ullrich
<?php print_info_box_np("The DNS forwarder configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
117
<?php endif; ?>
118 4d6ba181 Scott Ullrich
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
119 f0fe3d30 Scott Ullrich
                <tr>
120
                  <td class="vtable"><p>
121 6a01ea44 Bill Marquette
                      <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable'] == "yes") echo "checked";?> onClick="enable_change(false)">
122 5b237745 Scott Ullrich
                      <strong>Enable DNS forwarder<br>
123
                      </strong></p></td>
124
                </tr>
125 f0fe3d30 Scott Ullrich
                <tr>
126
                  <td class="vtable"><p>
127 5b237745 Scott Ullrich
                      <input name="regdhcp" type="checkbox" id="regdhcp" value="yes" <?php if ($pconfig['regdhcp'] == "yes") echo "checked";?>>
128
                      <strong>Register DHCP leases in DNS forwarder<br>
129 f0fe3d30 Scott Ullrich
                      </strong>If this option is set, then machines that specify
130
                      their hostname when requesting a DHCP lease will be registered
131
                      in the DNS forwarder, so that their name can be resolved.
132
                      You should also set the domain in <a href="system.php">System:
133 5b237745 Scott Ullrich
                      General setup</a> to the proper value.</p>
134
                    </td>
135
                </tr>
136 f0fe3d30 Scott Ullrich
                <tr>
137 6a01ea44 Bill Marquette
                  <td class="vtable"><p>
138
                      <input name="regdhcpstatic" type="checkbox" id="regdhcpstatic" value="yes" <?php if ($pconfig['regdhcpstatic'] == "yes") echo "checked";?>>
139
                      <strong>Register DHCP static mappings in DNS forwarder<br>
140
                      </strong>If this option is set, then DHCP static mappings will 
141
					  be registered in the DNS forwarder, so that their name can be 
142
					  resolved. You should also set the domain in <a href="system.php">
143
					  System: General setup</a> to the proper value.</p>
144
                    </td>
145
                </tr>				
146
                <tr>
147
                  <td> <input name="submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
148 5b237745 Scott Ullrich
                  </td>
149
                </tr>
150 f0fe3d30 Scott Ullrich
                <tr>
151 5b237745 Scott Ullrich
                  <td><p><span class="vexpl"><span class="red"><strong>Note:<br>
152 f0fe3d30 Scott Ullrich
                      </strong></span>If the DNS forwarder is enabled, the DHCP
153
                      service (if enabled) will automatically serve the LAN IP
154
                      address as a DNS server to DHCP clients so they will use
155
                      the forwarder. The DNS forwarder will use the DNS servers
156
                      entered in <a href="system.php">System: General setup</a>
157
                      or those obtained via DHCP or PPP on WAN if the &quot;Allow
158 dacefa7f Scott Ullrich
                      DNS server list to be overridden by DHCP/PPP on WAN&quot;
159 f0fe3d30 Scott Ullrich
                      is checked. If you don't use that option (or if you use
160
                      a static IP address on WAN), you must manually specify at
161
                      least one DNS server on the <a href="system.php">System:
162 5b237745 Scott Ullrich
                      General setup</a> page.<br>
163
                      <br>
164 f0fe3d30 Scott Ullrich
                      You may enter records that override the results from the
165 dacefa7f Scott Ullrich
                      forwarders below.</span></p></td>
166 5b237745 Scott Ullrich
                </tr>
167 4d6ba181 Scott Ullrich
        </table>
168
        &nbsp;<br>
169
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
170 5b237745 Scott Ullrich
                <tr>
171
                  <td width="20%" class="listhdrr">Host</td>
172
                  <td width="25%" class="listhdrr">Domain</td>
173
                  <td width="20%" class="listhdrr">IP</td>
174
                  <td width="25%" class="listhdr">Description</td>
175 d415d821 Seth Mos
                  <td width="10%" class="list">
176
                    <table border="0" cellspacing="0" cellpadding="1">
177
                      <tr>
178
			<td width="17"></td>
179
                        <td valign="middle"><a href="services_dnsmasq_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
180
                      </tr>
181
                    </table>
182
		  </td>
183
		</tr>
184 5b237745 Scott Ullrich
			  <?php $i = 0; foreach ($a_hosts as $hostent): ?>
185
                <tr>
186 835f9aca Bill Marquette
                  <td class="listlr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
187 5b237745 Scott Ullrich
                    <?=strtolower($hostent['host']);?>&nbsp;
188
                  </td>
189 835f9aca Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
190 5b237745 Scott Ullrich
                    <?=strtolower($hostent['domain']);?>&nbsp;
191
                  </td>
192 835f9aca Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
193 5b237745 Scott Ullrich
                    <?=$hostent['ip'];?>&nbsp;
194
                  </td>
195 835f9aca Bill Marquette
                  <td class="listbg" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
196 0e1dce26 Scott Ullrich
                    <?=htmlspecialchars($hostent['descr']);?>&nbsp;
197 5b237745 Scott Ullrich
                  </td>
198 ebe566eb Bill Marquette
                  <td valign="middle" nowrap class="list">
199
                    <table border="0" cellspacing="0" cellpadding="1">
200
                      <tr>
201 677c0869 Erik Kristensen
                        <td valign="middle"><a href="services_dnsmasq_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
202
                        <td><a href="services_dnsmasq.php?type=host&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this host?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
203 ebe566eb Bill Marquette
		      </tr>
204
                   </table>
205
                </tr>
206
		<?php $i++; endforeach; ?>
207 f0fe3d30 Scott Ullrich
                <tr>
208 5b237745 Scott Ullrich
                  <td class="list" colspan="4"></td>
209 ebe566eb Bill Marquette
                  <td class="list">
210
                    <table border="0" cellspacing="0" cellpadding="1">
211
                      <tr>
212 d415d821 Seth Mos
			<td width="17"></td>
213 677c0869 Erik Kristensen
                        <td valign="middle"><a href="services_dnsmasq_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
214 ebe566eb Bill Marquette
                      </tr>
215
                    </table>
216 ed137452 Scott Ullrich
		   </td>
217 4d6ba181 Scott Ullrich
	</table>
218 0c2b5df7 Scott Ullrich
<!-- update to enable domain overrides -->
219 4d6ba181 Scott Ullrich
        <table width="100%" border="0" cellpadding="6" cellspacing="0">
220 c21d4582 Scott Ullrich
	       <tr><td>&nbsp;</td></tr>
221 0c2b5df7 Scott Ullrich
               <tr>
222
                 <td><p>Below you can override an entire domain by specifying an
223
                        authoritative dns server to be queried for that domain.</p></td>
224
               </tr>
225 4d6ba181 Scott Ullrich
        </table>
226
	&nbsp;<br>
227
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
228 0c2b5df7 Scott Ullrich
               <tr>
229
                 <td width="35%" class="listhdrr">Domain</td>
230
                 <td width="20%" class="listhdrr">IP</td>
231
                 <td width="35%" class="listhdr">Description</td>
232 d415d821 Seth Mos
                 <td width="10%" class="list">
233
			<table border="0" cellspacing="0" cellpadding="1">
234
			    <tr>
235
				<td width="17" heigth="17"></td>			
236
				<td><a href="services_dnsmasq_domainoverride_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
237
			    </tr>
238
			</table>
239
		 </td>
240 0c2b5df7 Scott Ullrich
                              </tr>
241
                        <?php $i = 0; foreach ($a_domainOverrides as $doment): ?>
242
               <tr>
243
                 <td class="listlr">
244
                   <?=strtolower($doment['domain']);?>&nbsp;
245
                 </td>
246
                 <td class="listr">
247
                   <?=$doment['ip'];?>&nbsp;
248
                 </td>
249 d4da6249 Scott Ullrich
                 <td class="listbg">
250 0c2b5df7 Scott Ullrich
                   <?=htmlspecialchars($doment['descr']);?>&nbsp;
251
                 </td>
252 677c0869 Erik Kristensen
                 <td valign="middle" nowrap class="list"> <a href="services_dnsmasq_domainoverride_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
253
                    &nbsp;<a href="services_dnsmasq.php?act=del&type=doverride&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this domain override?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
254 0c2b5df7 Scott Ullrich
                              </tr>
255
                        <?php $i++; endforeach; ?>
256
               <tr>
257
                 <td class="list" colspan="3"></td>
258 d415d821 Seth Mos
                 <td class="list">
259
			<table border="0" cellspacing="0" cellpadding="1">
260
			    <tr>
261
				<td width="17" heigth="17"></td>			
262
				<td><a href="services_dnsmasq_domainoverride_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
263
			    </tr>
264
			</table>
265
		 </td>
266 0c2b5df7 Scott Ullrich
	       </tr>
267 4d6ba181 Scott Ullrich
        </table>
268
        </form>
269 6a01ea44 Bill Marquette
<script language="JavaScript">
270
<!--
271
enable_change(false);
272
//-->
273
</script>
274 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
275
</body>
276
</html>