1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
services_dnsmasq.php
|
5
|
part of m0n0wall (http://m0n0.ch/wall)
|
6
|
|
7
|
Copyright (C) 2003-2004 Bob Zoller <bob@kludgebox.com> and Manuel Kasper <mk@neon1.net>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
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
|
|
20
|
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
|
pfSense_MODULE: dnsforwarder
|
33
|
*/
|
34
|
|
35
|
##|+PRIV
|
36
|
##|*IDENT=page-services-dnsforwarder
|
37
|
##|*NAME=Services: DNS Forwarder page
|
38
|
##|*DESCR=Allow access to the 'Services: DNS Forwarder' page.
|
39
|
##|*MATCH=services_dnsmasq.php*
|
40
|
##|-PRIV
|
41
|
|
42
|
require("guiconfig.inc");
|
43
|
require_once("functions.inc");
|
44
|
require_once("filter.inc");
|
45
|
require_once("shaper.inc");
|
46
|
|
47
|
$pconfig['enable'] = isset($config['dnsmasq']['enable']);
|
48
|
$pconfig['regdhcp'] = isset($config['dnsmasq']['regdhcp']);
|
49
|
$pconfig['regdhcpstatic'] = isset($config['dnsmasq']['regdhcpstatic']);
|
50
|
|
51
|
if (!is_array($config['dnsmasq']['hosts']))
|
52
|
$config['dnsmasq']['hosts'] = array();
|
53
|
|
54
|
if (!is_array($config['dnsmasq']['domainoverrides']))
|
55
|
$config['dnsmasq']['domainoverrides'] = array();
|
56
|
|
57
|
|
58
|
$a_hosts = &$config['dnsmasq']['hosts'];
|
59
|
$a_domainOverrides = &$config['dnsmasq']['domainoverrides'];
|
60
|
|
61
|
if ($_POST) {
|
62
|
|
63
|
$pconfig = $_POST;
|
64
|
|
65
|
$config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false;
|
66
|
$config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false;
|
67
|
$config['dnsmasq']['regdhcpstatic'] = ($_POST['regdhcpstatic']) ? true : false;
|
68
|
|
69
|
write_config();
|
70
|
|
71
|
$retval = 0;
|
72
|
$retval = services_dnsmasq_configure();
|
73
|
$savemsg = get_std_save_message($retval);
|
74
|
|
75
|
// Relaod filter (we might need to sync to CARP hosts)
|
76
|
filter_configure();
|
77
|
|
78
|
if ($retval == 0)
|
79
|
clear_subsystem_dirty('hosts');
|
80
|
}
|
81
|
|
82
|
if ($_GET['act'] == "del") {
|
83
|
if ($_GET['type'] == 'host') {
|
84
|
if ($a_hosts[$_GET['id']]) {
|
85
|
unset($a_hosts[$_GET['id']]);
|
86
|
write_config();
|
87
|
mark_subsystem_dirty('hosts');
|
88
|
header("Location: services_dnsmasq.php");
|
89
|
exit;
|
90
|
}
|
91
|
}
|
92
|
elseif ($_GET['type'] == 'doverride') {
|
93
|
if ($a_domainOverrides[$_GET['id']]) {
|
94
|
unset($a_domainOverrides[$_GET['id']]);
|
95
|
write_config();
|
96
|
mark_subsystem_dirty('hosts');
|
97
|
header("Location: services_dnsmasq.php");
|
98
|
exit;
|
99
|
}
|
100
|
}
|
101
|
}
|
102
|
|
103
|
$pgtitle = array(gettext("Services"),gettext("DNS forwarder"));
|
104
|
include("head.inc");
|
105
|
|
106
|
?>
|
107
|
|
108
|
<script language="JavaScript">
|
109
|
<!--
|
110
|
function enable_change(enable_over) {
|
111
|
var endis;
|
112
|
endis = !(document.iform.enable.checked || enable_over);
|
113
|
document.iform.regdhcp.disabled = endis;
|
114
|
document.iform.regdhcpstatic.disabled = endis;
|
115
|
}
|
116
|
//-->
|
117
|
</script>
|
118
|
|
119
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
120
|
<?php include("fbegin.inc"); ?>
|
121
|
<form action="services_dnsmasq.php" method="post" name="iform" id="iform">
|
122
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
123
|
<?php if (is_subsystem_dirty('hosts')): ?><p>
|
124
|
<?php print_info_box_np(gettext("The DNS forwarder configuration has been changed") . ".<br>" . gettext("You must apply the changes in order for them to take effect."));?><br>
|
125
|
<?php endif; ?>
|
126
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
127
|
<tr>
|
128
|
<td class="vtable"><p>
|
129
|
<input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable'] == "yes") echo "checked";?> onClick="enable_change(false)">
|
130
|
<strong><?=gettext("Enable DNS forwarder");?><br>
|
131
|
</strong></p></td>
|
132
|
</tr>
|
133
|
<tr>
|
134
|
<td class="vtable"><p>
|
135
|
<input name="regdhcp" type="checkbox" id="regdhcp" value="yes" <?php if ($pconfig['regdhcp'] == "yes") echo "checked";?>>
|
136
|
<strong><?=gettext("Register DHCP leases in DNS forwarder");?><br>
|
137
|
</strong><?php printf(gettext("If this option is set, then machines that specify".
|
138
|
" their hostname when requesting a DHCP lease will be registered".
|
139
|
" in the DNS forwarder, so that their name can be resolved.".
|
140
|
" You should also set the domain in %sSystem:".
|
141
|
" General setup%s to the proper value."),'<a href="system.php">','</a>')?></p>
|
142
|
</td>
|
143
|
</tr>
|
144
|
<tr>
|
145
|
<td class="vtable"><p>
|
146
|
<input name="regdhcpstatic" type="checkbox" id="regdhcpstatic" value="yes" <?php if ($pconfig['regdhcpstatic'] == "yes") echo "checked";?>>
|
147
|
<strong><?=gettext("Register DHCP static mappings in DNS forwarder");?><br>
|
148
|
</strong><?php printf(gettext("If this option is set, then DHCP static mappings will ".
|
149
|
"be registered in the DNS forwarder, so that their name can be ".
|
150
|
"resolved. You should also set the domain in %s".
|
151
|
"System: General setup%s to the proper value."),'<a href="system.php">','</a>');?></p>
|
152
|
</td>
|
153
|
</tr>
|
154
|
<tr>
|
155
|
<td>
|
156
|
<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)">
|
157
|
</td>
|
158
|
</tr>
|
159
|
<tr>
|
160
|
<td>
|
161
|
<p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
|
162
|
</strong></span><?php printf(gettext("If the DNS forwarder is enabled, the DHCP".
|
163
|
" service (if enabled) will automatically serve the LAN IP".
|
164
|
" address as a DNS server to DHCP clients so they will use".
|
165
|
" the forwarder. The DNS forwarder will use the DNS servers".
|
166
|
" entered in %sSystem: General setup%s".
|
167
|
" or those obtained via DHCP or PPP on WAN if the "Allow".
|
168
|
" DNS server list to be overridden by DHCP/PPP on WAN"".
|
169
|
" is checked. If you don't use that option (or if you use".
|
170
|
" a static IP address on WAN), you must manually specify at".
|
171
|
" least one DNS server on the %sSystem:".
|
172
|
"General setup%s page."),'<a href="system.php">','</a>','<a href="system.php">','</a>');?><br>
|
173
|
<br>
|
174
|
<?=gettext("You may enter records that override the results from the".
|
175
|
" forwarders below.");?></span></p>
|
176
|
</td>
|
177
|
</tr>
|
178
|
</table>
|
179
|
<br>
|
180
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="sortable">
|
181
|
<thead>
|
182
|
<tr>
|
183
|
<td width="20%" class="listhdrr"><?=gettext("Host");?></td>
|
184
|
<td width="25%" class="listhdrr"><?=gettext("Domain");?></td>
|
185
|
<td width="20%" class="listhdrr"><?=gettext("IP");?></td>
|
186
|
<td width="25%" class="listhdr"><?=gettext("Description");?></td>
|
187
|
<td width="10%" class="list">
|
188
|
<table border="0" cellspacing="0" cellpadding="1">
|
189
|
<tr>
|
190
|
<td width="17"></td>
|
191
|
<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>
|
192
|
</tr>
|
193
|
</table>
|
194
|
</td>
|
195
|
</tr>
|
196
|
</thead>
|
197
|
<tbody>
|
198
|
<?php $i = 0; foreach ($a_hosts as $hostent): ?>
|
199
|
<tr>
|
200
|
<td class="listlr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
|
201
|
<?=strtolower($hostent['host']);?>
|
202
|
</td>
|
203
|
<td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
|
204
|
<?=strtolower($hostent['domain']);?>
|
205
|
</td>
|
206
|
<td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
|
207
|
<?=$hostent['ip'];?>
|
208
|
</td>
|
209
|
<td class="listbg" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
|
210
|
<?=htmlspecialchars($hostent['descr']);?>
|
211
|
</td>
|
212
|
<td valign="middle" nowrap class="list">
|
213
|
<table border="0" cellspacing="0" cellpadding="1">
|
214
|
<tr>
|
215
|
<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>
|
216
|
<td><a href="services_dnsmasq.php?type=host&act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("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>
|
217
|
</tr>
|
218
|
</table>
|
219
|
</tr>
|
220
|
<?php $i++; endforeach; ?>
|
221
|
</tbody>
|
222
|
<tfoot>
|
223
|
<tr>
|
224
|
<td class="list" colspan="4"></td>
|
225
|
<td class="list">
|
226
|
<table border="0" cellspacing="0" cellpadding="1">
|
227
|
<tr>
|
228
|
<td width="17"></td>
|
229
|
<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>
|
230
|
</tr>
|
231
|
</table>
|
232
|
</td>
|
233
|
</tr>
|
234
|
</tfoot>
|
235
|
</table>
|
236
|
<!-- update to enable domain overrides -->
|
237
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
238
|
<tr><td> </td></tr>
|
239
|
<tr>
|
240
|
<td><p><?=gettext("Below you can override an entire domain by specifying an".
|
241
|
" authoritative DNS server to be queried for that domain.");?></p></td>
|
242
|
</tr>
|
243
|
</table>
|
244
|
<br>
|
245
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="sortable">
|
246
|
<thead>
|
247
|
<tr>
|
248
|
<td width="35%" class="listhdrr"><?=gettext("Domain");?></td>
|
249
|
<td width="20%" class="listhdrr"><?=gettext("IP");?></td>
|
250
|
<td width="35%" class="listhdr"><?=gettext("Description");?></td>
|
251
|
<td width="10%" class="list">
|
252
|
<table border="0" cellspacing="0" cellpadding="1">
|
253
|
<tr>
|
254
|
<td width="17" heigth="17"></td>
|
255
|
<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>
|
256
|
</tr>
|
257
|
</table>
|
258
|
</td>
|
259
|
</tr>
|
260
|
</thead>
|
261
|
<tbody>
|
262
|
<?php $i = 0; foreach ($a_domainOverrides as $doment): ?>
|
263
|
<tr>
|
264
|
<td class="listlr">
|
265
|
<?=strtolower($doment['domain']);?>
|
266
|
</td>
|
267
|
<td class="listr">
|
268
|
<?=$doment['ip'];?>
|
269
|
</td>
|
270
|
<td class="listbg">
|
271
|
<?=htmlspecialchars($doment['descr']);?>
|
272
|
</td>
|
273
|
<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>
|
274
|
<a href="services_dnsmasq.php?act=del&type=doverride&id=<?=$i;?>" onclick="return confirm('<?=gettext("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>
|
275
|
</tr>
|
276
|
<?php $i++; endforeach; ?>
|
277
|
</tbody>
|
278
|
<tfoot>
|
279
|
<tr>
|
280
|
<td class="list" colspan="3"></td>
|
281
|
<td class="list">
|
282
|
<table border="0" cellspacing="0" cellpadding="1">
|
283
|
<tr>
|
284
|
<td width="17" heigth="17"></td>
|
285
|
<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>
|
286
|
</tr>
|
287
|
</table>
|
288
|
</td>
|
289
|
</tr>
|
290
|
</tfoot>
|
291
|
</table>
|
292
|
</form>
|
293
|
<script language="JavaScript">
|
294
|
<!--
|
295
|
enable_change(false);
|
296
|
//-->
|
297
|
</script>
|
298
|
<?php include("fend.inc"); ?>
|
299
|
</body>
|
300
|
</html>
|