1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
services_dhcp.php
|
5
|
part of m0n0wall (http://m0n0.ch/wall)
|
6
|
|
7
|
Copyright (C) 2003-2004 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
|
require("guiconfig.inc");
|
33
|
|
34
|
$if = $_GET['if'];
|
35
|
if ($_POST['if'])
|
36
|
$if = $_POST['if'];
|
37
|
|
38
|
/* if OLSRD is enabled, allow WAN to house DHCP. */
|
39
|
if($config['installedpackages']['olsrd']) {
|
40
|
foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
|
41
|
if($olsrd['enable']) {
|
42
|
$iflist = array("lan" => "LAN", "wan" => "WAN");
|
43
|
$is_olsr_enabled = true;
|
44
|
break;
|
45
|
}
|
46
|
}
|
47
|
}
|
48
|
|
49
|
if(!$iflist)
|
50
|
$iflist = array("lan" => "LAN");
|
51
|
|
52
|
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
|
53
|
$oc = $config['interfaces']['opt' . $i];
|
54
|
|
55
|
if (isset($oc['enable']) && $oc['if'] && (!$oc['bridge'])) {
|
56
|
$iflist['opt' . $i] = $oc['descr'];
|
57
|
}
|
58
|
}
|
59
|
|
60
|
if (!$if || !isset($iflist[$if]))
|
61
|
$if = "lan";
|
62
|
|
63
|
$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
|
64
|
$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
|
65
|
$pconfig['deftime'] = $config['dhcpd'][$if]['defaultleasetime'];
|
66
|
$pconfig['maxtime'] = $config['dhcpd'][$if]['maxleasetime'];
|
67
|
$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
|
68
|
$pconfig['domain'] = $config['dhcpd'][$if]['domain'];
|
69
|
$pconfig['domainsearchlist'] = $config['dhcpd'][$if]['domainsearchlist'];
|
70
|
list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
|
71
|
list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
|
72
|
$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
|
73
|
$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
|
74
|
$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
|
75
|
$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
|
76
|
$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
|
77
|
list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
|
78
|
$pconfig['tftp'] = $config['dhcpd'][$if]['tftp'];
|
79
|
$pconfig['ldap'] = $config['dhcpd'][$if]['ldap'];
|
80
|
$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
|
81
|
$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
|
82
|
$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
|
83
|
$pconfig['rootpath'] = $config['dhcpd'][$if]['rootpath'];
|
84
|
$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
|
85
|
$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
|
86
|
|
87
|
$ifcfg = $config['interfaces'][$if];
|
88
|
|
89
|
|
90
|
/* set the enabled flag which will tell us if DHCP relay is enabled
|
91
|
* on any interface. We will use this to disable DHCP server since
|
92
|
* the two are not compatible with each other.
|
93
|
*/
|
94
|
|
95
|
$dhcrelay_enabled = false;
|
96
|
$dhcrelaycfg = $config['dhcrelay'];
|
97
|
|
98
|
if(is_array($dhcrelaycfg)) {
|
99
|
foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
|
100
|
if (isset($dhcrelayifconf['enable']) &&
|
101
|
(($dhcrelayif == "lan") ||
|
102
|
(isset($config['interfaces'][$dhcrelayif]['enable']) &&
|
103
|
$config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
|
104
|
$dhcrelay_enabled = true;
|
105
|
}
|
106
|
}
|
107
|
|
108
|
if (!is_array($config['dhcpd'][$if]['staticmap'])) {
|
109
|
$config['dhcpd'][$if]['staticmap'] = array();
|
110
|
}
|
111
|
staticmaps_sort($if);
|
112
|
$a_maps = &$config['dhcpd'][$if]['staticmap'];
|
113
|
|
114
|
function is_inrange($test, $start, $end) {
|
115
|
if ( (ip2long($test) < ip2long($end)) && (ip2long($test) > ip2long($start)) )
|
116
|
return true;
|
117
|
else
|
118
|
return false;
|
119
|
}
|
120
|
|
121
|
if ($_POST) {
|
122
|
|
123
|
unset($input_errors);
|
124
|
|
125
|
$pconfig = $_POST;
|
126
|
|
127
|
/* input validation */
|
128
|
if ($_POST['enable']) {
|
129
|
$reqdfields = explode(" ", "range_from range_to");
|
130
|
$reqdfieldsn = explode(",", "Range begin,Range end");
|
131
|
|
132
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
133
|
|
134
|
foreach($a_maps as $mapent) {
|
135
|
if(is_inrange($mapent['ipaddr'], $_POST['range_from'], $_POST['range_to'])) {
|
136
|
$input_errors[] = "{$mapent['ipaddr']} is inside the range you specified.";
|
137
|
}
|
138
|
|
139
|
}
|
140
|
|
141
|
if (($_POST['range_from'] && !is_ipaddr($_POST['range_from']))) {
|
142
|
$input_errors[] = "A valid range must be specified.";
|
143
|
}
|
144
|
if (($_POST['range_to'] && !is_ipaddr($_POST['range_to']))) {
|
145
|
$input_errors[] = "A valid range must be specified.";
|
146
|
}
|
147
|
if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
|
148
|
$input_errors[] = "A valid IP address must be specified for the gateway.";
|
149
|
}
|
150
|
if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2']))) {
|
151
|
$input_errors[] = "A valid IP address must be specified for the primary/secondary WINS servers.";
|
152
|
}
|
153
|
if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2']))) {
|
154
|
$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS servers.";
|
155
|
}
|
156
|
if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60))) {
|
157
|
$input_errors[] = "The default lease time must be at least 60 seconds.";
|
158
|
}
|
159
|
if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime']))) {
|
160
|
$input_errors[] = "The maximum lease time must be at least 60 seconds and higher than the default lease time.";
|
161
|
}
|
162
|
if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
|
163
|
$input_errors[] = "A valid domain name must be specified for the dynamic DNS registration.";
|
164
|
}
|
165
|
if (($_POST['ntp1'] && !is_ipaddr($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddr($_POST['ntp2']))) {
|
166
|
$input_errors[] = "A valid IP address must be specified for the primary/secondary NTP servers.";
|
167
|
}
|
168
|
if (($_POST['domain'] && !is_domain($_POST['domain']))) {
|
169
|
$input_errors[] = "A valid domain name must be specified for the DNS domain.";
|
170
|
}
|
171
|
if (($_POST['tftp'] && !is_ipaddr($_POST['tftp']))) {
|
172
|
$input_errors[] = "A valid IP address must be specified for the tftp server.";
|
173
|
}
|
174
|
if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver']))) {
|
175
|
$input_errors[] = "A valid IP address must be specified for the network boot server.";
|
176
|
}
|
177
|
|
178
|
if (!$input_errors) {
|
179
|
/* make sure the range lies within the current subnet */
|
180
|
$subnet_start = (ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));
|
181
|
$subnet_end = (ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])));
|
182
|
|
183
|
if ((ip2long($_POST['range_from']) < $subnet_start) || (ip2long($_POST['range_from']) > $subnet_end) ||
|
184
|
(ip2long($_POST['range_to']) < $subnet_start) || (ip2long($_POST['range_to']) > $subnet_end)) {
|
185
|
$input_errors[] = "The specified range lies outside of the current subnet.";
|
186
|
}
|
187
|
|
188
|
if (ip2long($_POST['range_from']) > ip2long($_POST['range_to']))
|
189
|
$input_errors[] = "The range is invalid (first element higher than second element).";
|
190
|
|
191
|
/* make sure that the DHCP Relay isn't enabled on this interface */
|
192
|
if (isset($config['dhcrelay'][$if]['enable']))
|
193
|
$input_errors[] = "You must disable the DHCP relay on the {$iflist[$if]} interface before enabling the DHCP server.";
|
194
|
}
|
195
|
}
|
196
|
|
197
|
if (!$input_errors) {
|
198
|
$config['dhcpd'][$if]['range']['from'] = $_POST['range_from'];
|
199
|
$config['dhcpd'][$if]['range']['to'] = $_POST['range_to'];
|
200
|
$config['dhcpd'][$if]['defaultleasetime'] = $_POST['deftime'];
|
201
|
$config['dhcpd'][$if]['maxleasetime'] = $_POST['maxtime'];
|
202
|
$config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
|
203
|
$previous = $config['dhcpd'][$if]['failover_peerip'];
|
204
|
if($previous <> $_POST['failover_peerip']) {
|
205
|
mwexec("rm -rf /var/dhcpd/var/db/*");
|
206
|
}
|
207
|
$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
|
208
|
|
209
|
unset($config['dhcpd'][$if]['winsserver']);
|
210
|
if ($_POST['wins1'])
|
211
|
$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
|
212
|
if ($_POST['wins2'])
|
213
|
$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
|
214
|
|
215
|
unset($config['dhcpd'][$if]['dnsserver']);
|
216
|
if ($_POST['dns1'])
|
217
|
$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
|
218
|
if ($_POST['dns2'])
|
219
|
$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
|
220
|
|
221
|
$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
|
222
|
$config['dhcpd'][$if]['domain'] = $_POST['domain'];
|
223
|
$config['dhcpd'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
|
224
|
$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
|
225
|
$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
|
226
|
$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
|
227
|
$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
|
228
|
$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
|
229
|
|
230
|
unset($config['dhcpd'][$if]['ntpserver']);
|
231
|
if ($_POST['ntp1'])
|
232
|
$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
|
233
|
if ($_POST['ntp2'])
|
234
|
$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
|
235
|
|
236
|
$config['dhcpd'][$if]['tftp'] = $_POST['tftp'];
|
237
|
$config['dhcpd'][$if]['ldap'] = $_POST['ldap'];
|
238
|
$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
|
239
|
$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
|
240
|
$config['dhcpd'][$if]['filename'] = $_POST['filename'];
|
241
|
$config['dhcpd'][$if]['rootpath'] = $_POST['rootpath'];
|
242
|
|
243
|
write_config();
|
244
|
|
245
|
/* static arp configuration */
|
246
|
interfaces_staticarp_configure($if);
|
247
|
|
248
|
$retval = 0;
|
249
|
$retvaldhcp = 0;
|
250
|
$retvaldns = 0;
|
251
|
config_lock();
|
252
|
/* dnsmasq_configure calls dhcpd_configure */
|
253
|
/* no need to restart dhcpd twice */
|
254
|
if (isset($config['dnsmasq']['regdhcpstatic'])) {
|
255
|
$retvaldns = services_dnsmasq_configure();
|
256
|
if ($retvaldns == 0) {
|
257
|
if (file_exists($d_hostsdirty_path))
|
258
|
unlink($d_hostsdirty_path);
|
259
|
if (file_exists($d_staticmapsdirty_path))
|
260
|
unlink($d_staticmapsdirty_path);
|
261
|
}
|
262
|
} else {
|
263
|
$retvaldhcp = services_dhcpd_configure();
|
264
|
if ($retvaldhcp == 0) {
|
265
|
if (file_exists($d_staticmapsdirty_path))
|
266
|
unlink($d_staticmapsdirty_path);
|
267
|
}
|
268
|
}
|
269
|
config_unlock();
|
270
|
if($retvaldhcp == 1 || $retvaldns == 1)
|
271
|
$retval = 1;
|
272
|
$savemsg = get_std_save_message($retval);
|
273
|
}
|
274
|
}
|
275
|
|
276
|
if ($_GET['act'] == "del") {
|
277
|
if ($a_maps[$_GET['id']]) {
|
278
|
unset($a_maps[$_GET['id']]);
|
279
|
write_config();
|
280
|
if(isset($config['dhcpd'][$if]['enable'])) {
|
281
|
touch($d_staticmapsdirty_path);
|
282
|
if (isset($config['dnsmasq']['regdhcpstatic']))
|
283
|
touch($d_hostsdirty_path);
|
284
|
}
|
285
|
header("Location: services_dhcp.php?if={$if}");
|
286
|
exit;
|
287
|
}
|
288
|
}
|
289
|
|
290
|
$pgtitle = "Services: DHCP server";
|
291
|
include("head.inc");
|
292
|
|
293
|
?>
|
294
|
|
295
|
<script type="text/javascript" language="JavaScript">
|
296
|
|
297
|
function enable_change(enable_over) {
|
298
|
var endis;
|
299
|
endis = !(document.iform.enable.checked || enable_over);
|
300
|
document.iform.range_from.disabled = endis;
|
301
|
document.iform.range_to.disabled = endis;
|
302
|
document.iform.wins1.disabled = endis;
|
303
|
document.iform.wins2.disabled = endis;
|
304
|
document.iform.dns1.disabled = endis;
|
305
|
document.iform.dns2.disabled = endis;
|
306
|
document.iform.deftime.disabled = endis;
|
307
|
document.iform.maxtime.disabled = endis;
|
308
|
document.iform.gateway.disabled = endis;
|
309
|
document.iform.failover_peerip.disabled = endis;
|
310
|
document.iform.domain.disabled = endis;
|
311
|
document.iform.domainsearchlist.disabled = endis;
|
312
|
document.iform.staticarp.disabled = endis;
|
313
|
document.iform.ddnsdomain.disabled = endis;
|
314
|
document.iform.ddnsupdate.disabled = endis;
|
315
|
document.iform.ntp1.disabled = endis;
|
316
|
document.iform.ntp2.disabled = endis;
|
317
|
document.iform.tftp.disabled = endis;
|
318
|
document.iform.ldap.disabled = endis;
|
319
|
document.iform.netboot.disabled = endis;
|
320
|
document.iform.nextserver.disabled = endis;
|
321
|
document.iform.filename.disabled = endis;
|
322
|
document.iform.rootpath.disabled = endis;
|
323
|
document.iform.denyunknown.disabled = endis;
|
324
|
}
|
325
|
|
326
|
function show_ddns_config() {
|
327
|
document.getElementById("showddnsbox").innerHTML='';
|
328
|
aodiv = document.getElementById('showddns');
|
329
|
aodiv.style.display = "block";
|
330
|
}
|
331
|
|
332
|
function show_ntp_config() {
|
333
|
document.getElementById("showntpbox").innerHTML='';
|
334
|
aodiv = document.getElementById('showntp');
|
335
|
aodiv.style.display = "block";
|
336
|
}
|
337
|
|
338
|
function show_tftp_config() {
|
339
|
document.getElementById("showtftpbox").innerHTML='';
|
340
|
aodiv = document.getElementById('showtftp');
|
341
|
aodiv.style.display = "block";
|
342
|
}
|
343
|
|
344
|
function show_ldap_config() {
|
345
|
document.getElementById("showldapbox").innerHTML='';
|
346
|
aodiv = document.getElementById('showldap');
|
347
|
aodiv.style.display = "block";
|
348
|
}
|
349
|
|
350
|
function show_netboot_config() {
|
351
|
document.getElementById("shownetbootbox").innerHTML='';
|
352
|
aodiv = document.getElementById('shownetboot');
|
353
|
aodiv.style.display = "block";
|
354
|
}
|
355
|
|
356
|
</script>
|
357
|
|
358
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
359
|
<?php include("fbegin.inc"); ?>
|
360
|
<p class="pgtitle"><?=$pgtitle?></p>
|
361
|
<form action="services_dhcp.php" method="post" name="iform" id="iform">
|
362
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
363
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
364
|
<?php
|
365
|
if ($dhcrelay_enabled) {
|
366
|
echo "DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.";
|
367
|
include("fend.inc");
|
368
|
echo "</body>";
|
369
|
echo "</html>";
|
370
|
exit;
|
371
|
}
|
372
|
?>
|
373
|
<?php if (file_exists($d_staticmapsdirty_path)): ?><p>
|
374
|
<?php print_info_box_np("The static mapping configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
|
375
|
<?php endif; ?>
|
376
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
377
|
<tr><td>
|
378
|
<?php
|
379
|
/* active tabs */
|
380
|
$tab_array = array();
|
381
|
$tabscounter = 0;
|
382
|
$i = 0;
|
383
|
foreach ($iflist as $ifent => $ifname) {
|
384
|
if ($ifent == $if)
|
385
|
$active = true;
|
386
|
else
|
387
|
$active = false;
|
388
|
$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
|
389
|
}
|
390
|
display_top_tabs($tab_array);
|
391
|
?>
|
392
|
</td></tr>
|
393
|
<tr>
|
394
|
<td>
|
395
|
<div id="mainarea">
|
396
|
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
|
397
|
<tr>
|
398
|
<td width="22%" valign="top" class="vtable"> </td>
|
399
|
<td width="78%" class="vtable">
|
400
|
<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
|
401
|
<strong>Enable DHCP server on
|
402
|
<?=htmlspecialchars($iflist[$if]);?>
|
403
|
interface</strong></td>
|
404
|
</tr>
|
405
|
<tr>
|
406
|
<td width="22%" valign="top" class="vtable"> </td>
|
407
|
<td width="78%" class="vtable">
|
408
|
<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
|
409
|
<strong>Deny unknown clients</strong><br>
|
410
|
If this is checked, only the clients defined below will get DHCP leases from this server. </td>
|
411
|
</tr>
|
412
|
<tr>
|
413
|
<td width="22%" valign="top" class="vncellreq">Subnet</td>
|
414
|
<td width="78%" class="vtable">
|
415
|
<?=gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']);?>
|
416
|
</td>
|
417
|
</tr>
|
418
|
<tr>
|
419
|
<td width="22%" valign="top" class="vncellreq">Subnet
|
420
|
mask</td>
|
421
|
<td width="78%" class="vtable">
|
422
|
<?=gen_subnet_mask($ifcfg['subnet']);?>
|
423
|
</td>
|
424
|
</tr>
|
425
|
<tr>
|
426
|
<td width="22%" valign="top" class="vncellreq">Available
|
427
|
range</td>
|
428
|
<td width="78%" class="vtable">
|
429
|
<?=long2ip(ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));?>
|
430
|
-
|
431
|
<?=long2ip(ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet']))); ?>
|
432
|
</td>
|
433
|
</tr>
|
434
|
<?php if($is_olsr_enabled): ?>
|
435
|
<tr>
|
436
|
<td width="22%" valign="top" class="vncellreq">Subnet Mask</td>
|
437
|
<td width="78%" class="vtable">
|
438
|
<select name="netmask" class="formselect" id="netmask">
|
439
|
<?php
|
440
|
for ($i = 32; $i > 0; $i--) {
|
441
|
if($i <> 31) {
|
442
|
echo "<option value=\"{$i}\" ";
|
443
|
if ($i == $pconfig['subnet']) echo "selected";
|
444
|
echo ">" . $i . "</option>";
|
445
|
}
|
446
|
}
|
447
|
?>
|
448
|
</select>
|
449
|
</td>
|
450
|
</tr>
|
451
|
<?php endif; ?>
|
452
|
<tr>
|
453
|
<td width="22%" valign="top" class="vncellreq">Range</td>
|
454
|
<td width="78%" class="vtable">
|
455
|
<input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>">
|
456
|
to <input name="range_to" type="text" class="formfld unknown" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>">
|
457
|
</td>
|
458
|
</tr>
|
459
|
<tr>
|
460
|
<td width="22%" valign="top" class="vncell">WINS servers</td>
|
461
|
<td width="78%" class="vtable">
|
462
|
<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>"><br>
|
463
|
<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>">
|
464
|
</td>
|
465
|
</tr>
|
466
|
<tr>
|
467
|
<td width="22%" valign="top" class="vncell">DNS servers</td>
|
468
|
<td width="78%" class="vtable">
|
469
|
<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
|
470
|
<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
|
471
|
NOTE: leave blank to use the system default DNS servers. This option is handy when your doing CARP+DHCP Failover, etc.
|
472
|
</td>
|
473
|
</tr>
|
474
|
<tr>
|
475
|
<td width="22%" valign="top" class="vncell">Gateway</td>
|
476
|
<td width="78%" class="vtable">
|
477
|
<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
|
478
|
The default is to use the IP of the firewall as the gateway. Specify an alternate gateway here if this is not the correct gateway for your network.
|
479
|
</td>
|
480
|
</tr>
|
481
|
<tr>
|
482
|
<td width="22%" valign="top" class="vncell">Domain-Name</td>
|
483
|
<td width="78%" class="vtable">
|
484
|
<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>"><br>
|
485
|
The default is to use the domainname of the router as DNS-Search string that is served via DHCP. Specify an alternate DNS-Search string here.
|
486
|
</td>
|
487
|
</tr>
|
488
|
<tr>
|
489
|
<td width="22%" valign="top" class="vncell">Domain-Searchlist</td>
|
490
|
<td width="78%" class="vtable">
|
491
|
<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>"><br>
|
492
|
DNS-Searchlist: the DHCP server can serve a list of domains to be searched.
|
493
|
</td>
|
494
|
</tr>
|
495
|
<tr>
|
496
|
<td width="22%" valign="top" class="vncell">Default lease time</td>
|
497
|
<td width="78%" class="vtable">
|
498
|
<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
|
499
|
seconds<br>
|
500
|
This is used for clients that do not ask for a specific
|
501
|
expiration time.<br>
|
502
|
The default is 7200 seconds.
|
503
|
</td>
|
504
|
</tr>
|
505
|
<tr>
|
506
|
<td width="22%" valign="top" class="vncell">Maximum lease time</td>
|
507
|
<td width="78%" class="vtable">
|
508
|
<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
|
509
|
seconds<br>
|
510
|
This is the maximum lease time for clients that ask
|
511
|
for a specific expiration time.<br>
|
512
|
The default is 86400 seconds.
|
513
|
</td>
|
514
|
</tr>
|
515
|
<tr>
|
516
|
<td width="22%" valign="top" class="vncell">Failover peer IP:</td>
|
517
|
<td width="78%" class="vtable">
|
518
|
<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
|
519
|
Leave blank to disable. Enter the REAL address of the other machine. Machines must be using CARP.
|
520
|
</td>
|
521
|
</tr>
|
522
|
<tr>
|
523
|
<td width="22%" valign="top" class="vncell">Static ARP</td>
|
524
|
<td width="78%" class="vtable">
|
525
|
<table>
|
526
|
<tr>
|
527
|
<td>
|
528
|
<input valign="middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked"; ?>>
|
529
|
</td>
|
530
|
<td>
|
531
|
<b>Enable Static ARP entries</b>
|
532
|
</td>
|
533
|
</tr>
|
534
|
<tr>
|
535
|
<td>
|
536
|
|
537
|
</td>
|
538
|
<td>
|
539
|
<span class="red"><strong>Note:</strong></span> Only the machines listed below will be able to communicate with the firewall on this NIC.
|
540
|
</td>
|
541
|
</tr>
|
542
|
</table>
|
543
|
</td>
|
544
|
</tr>
|
545
|
<tr>
|
546
|
<td width="22%" valign="top" class="vncell">Dynamic DNS</td>
|
547
|
<td width="78%" class="vtable">
|
548
|
<div id="showddnsbox">
|
549
|
<input type="button" onClick="show_ddns_config()" value="Advanced"></input> - Show Dynamic DNS</a>
|
550
|
</div>
|
551
|
<div id="showddns" style="display:none">
|
552
|
<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>
|
553
|
<b>Enable registration of DHCP client names in DNS.</b><br />
|
554
|
<p>
|
555
|
<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
|
556
|
Note: Leave blank to disable dynamic DNS registration.<br />
|
557
|
Enter the dynamic DNS domain which will be used to register client names in the DNS server.
|
558
|
</div>
|
559
|
</td>
|
560
|
</tr>
|
561
|
<tr>
|
562
|
<td width="22%" valign="top" class="vncell">NTP servers</td>
|
563
|
<td width="78%" class="vtable">
|
564
|
<div id="showntpbox">
|
565
|
<input type="button" onClick="show_ntp_config()" value="Advanced"></input> - Show NTP configuration</a>
|
566
|
</div>
|
567
|
<div id="showntp" style="display:none">
|
568
|
<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
|
569
|
<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
|
570
|
</div>
|
571
|
</td>
|
572
|
</tr>
|
573
|
<tr>
|
574
|
<td width="22%" valign="top" class="vncell">TFTP server</td>
|
575
|
<td width="78%" class="vtable">
|
576
|
<div id="showtftpbox">
|
577
|
<input type="button" onClick="show_tftp_config()" value="Advanced"></input> - Show TFTP configuration</a>
|
578
|
</div>
|
579
|
<div id="showtftp" style="display:none">
|
580
|
<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
|
581
|
Leave blank to disable. Enter a full hostname or IP for the TFTP server.
|
582
|
</div>
|
583
|
</td>
|
584
|
</tr>
|
585
|
<tr>
|
586
|
<td width="22%" valign="top" class="vncell">LDAP URI</td>
|
587
|
<td width="78%" class="vtable">
|
588
|
<div id="showldapbox">
|
589
|
<input type="button" onClick="show_ldap_config()" value="Advanced"></input> - Show LDAP configuration</a>
|
590
|
</div>
|
591
|
<div id="showldap" style="display:none">
|
592
|
<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
|
593
|
Leave blank to disable. Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com
|
594
|
</div>
|
595
|
</td>
|
596
|
</tr>
|
597
|
<tr>
|
598
|
<td width="22%" valign="top" class="vncell">Enable Network booting</td>
|
599
|
<td width="78%" class="vtable">
|
600
|
<div id="shownetbootbox">
|
601
|
<input type="button" onClick="show_netboot_config()" value="Advanced"></input> - Show Network booting</a>
|
602
|
</div>
|
603
|
<div id="shownetboot" style="display:none">
|
604
|
<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>
|
605
|
<b>Enables network booting.</b>
|
606
|
<p>
|
607
|
Enter the IP of the <b>next-server</b>
|
608
|
<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>">
|
609
|
and the filename
|
610
|
<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
|
611
|
Note: You need both a filename and a boot server configured for this to work!
|
612
|
<p>
|
613
|
Enter the <b>root-path</b>-string
|
614
|
<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
|
615
|
Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname
|
616
|
</div>
|
617
|
</td>
|
618
|
</tr>
|
619
|
<tr>
|
620
|
<td width="22%" valign="top"> </td>
|
621
|
<td width="78%">
|
622
|
<input name="if" type="hidden" value="<?=$if;?>">
|
623
|
<input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
|
624
|
</td>
|
625
|
</tr>
|
626
|
<tr>
|
627
|
<td width="22%" valign="top"> </td>
|
628
|
<td width="78%"> <p><span class="vexpl"><span class="red"><strong>Note:<br>
|
629
|
</strong></span>The DNS servers entered in <a href="system.php">System:
|
630
|
General setup</a> (or the <a href="services_dnsmasq.php">DNS
|
631
|
forwarder</a>, if enabled) </span><span class="vexpl">will
|
632
|
be assigned to clients by the DHCP server.<br>
|
633
|
<br>
|
634
|
The DHCP lease table can be viewed on the <a href="diag_dhcp_leases.php">Diagnostics:
|
635
|
DHCP leases</a> page.<br>
|
636
|
</span></p>
|
637
|
</td>
|
638
|
</tr>
|
639
|
</table>
|
640
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
641
|
<tr>
|
642
|
<td width="25%" class="listhdrr">MAC address</td>
|
643
|
<td width="15%" class="listhdrr">IP address</td>
|
644
|
<td width="20%" class="listhdrr">Hostname</td>
|
645
|
<td width="30%" class="listhdr">Description</td>
|
646
|
<td width="10%" class="list">
|
647
|
<table border="0" cellspacing="0" cellpadding="1">
|
648
|
<tr>
|
649
|
<td valign="middle" width="17"></td>
|
650
|
<td valign="middle"><a href="services_dhcp_edit.php?if=<?=$if;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
651
|
</tr>
|
652
|
</table>
|
653
|
</td>
|
654
|
</tr>
|
655
|
<?php if(is_array($a_maps)): ?>
|
656
|
<?php $i = 0; foreach ($a_maps as $mapent): ?>
|
657
|
<?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
|
658
|
<tr>
|
659
|
<td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
|
660
|
<?=htmlspecialchars($mapent['mac']);?>
|
661
|
</td>
|
662
|
<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
|
663
|
<?=htmlspecialchars($mapent['ipaddr']);?>
|
664
|
</td>
|
665
|
<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
|
666
|
<?=htmlspecialchars($mapent['hostname']);?>
|
667
|
</td>
|
668
|
<td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
|
669
|
<font color="#FFFFFF"><?=htmlspecialchars($mapent['descr']);?> </font>
|
670
|
</td>
|
671
|
<td valign="middle" nowrap class="list">
|
672
|
<table border="0" cellspacing="0" cellpadding="1">
|
673
|
<tr>
|
674
|
<td valign="middle"><a href="services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
|
675
|
<td valign="middle"><a href="services_dhcp.php?if=<?=$if;?>&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this mapping?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
|
676
|
</tr>
|
677
|
</table>
|
678
|
</td>
|
679
|
</tr>
|
680
|
<?php endif; ?>
|
681
|
<?php $i++; endforeach; ?>
|
682
|
<?php endif; ?>
|
683
|
<tr>
|
684
|
<td class="list" colspan="4"></td>
|
685
|
<td class="list">
|
686
|
<table border="0" cellspacing="0" cellpadding="1">
|
687
|
<tr>
|
688
|
<td valign="middle" width="17"></td>
|
689
|
<td valign="middle"><a href="services_dhcp_edit.php?if=<?=$if;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
690
|
</tr>
|
691
|
</table>
|
692
|
</td>
|
693
|
</tr>
|
694
|
</table>
|
695
|
</div>
|
696
|
</td>
|
697
|
</tr>
|
698
|
</table>
|
699
|
</form>
|
700
|
<script language="JavaScript">
|
701
|
<!--
|
702
|
enable_change(false);
|
703
|
//-->
|
704
|
</script>
|
705
|
<?php include("fend.inc"); ?>
|
706
|
</body>
|
707
|
</html>
|