Project

General

Profile

Download (31.2 KB) Statistics
| Branch: | Tag: | Revision:
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 = array("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
<form action="services_dhcp.php" method="post" name="iform" id="iform">
361
<?php if ($input_errors) print_input_errors($input_errors); ?>
362
<?php if ($savemsg) print_info_box($savemsg); ?>
363
<?php 
364
	if ($dhcrelay_enabled) {
365
		echo "DHCP Relay is currently enabled.  Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.";
366
		include("fend.inc"); 
367
		echo "</body>";
368
		echo "</html>";
369
		exit;
370
	}
371
?>
372
<?php if (file_exists($d_staticmapsdirty_path)): ?><p>
373
<?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>
374
<?php endif; ?>
375
<table width="100%" border="0" cellpadding="0" cellspacing="0">
376
  <tr><td>
377
  <?php
378
	/* active tabs */
379
	$tab_array = array();
380
	$tabscounter = 0;
381
	$i = 0;
382
	foreach ($iflist as $ifent => $ifname) {
383
		if ($ifent == $if)
384
			$active = true;
385
		else
386
			$active = false;
387
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
388
	}
389
	display_top_tabs($tab_array);
390
  ?>
391
  </td></tr>
392
  <tr>
393
    <td>
394
	<div id="mainarea">
395
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
396
                      <tr>
397
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
398
                        <td width="78%" class="vtable">
399
			  <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
400
                          <strong>Enable DHCP server on
401
                          <?=htmlspecialchars($iflist[$if]);?>
402
                          interface</strong></td>
403
                      </tr>
404
				  <tr>
405
	              <td width="22%" valign="top" class="vtable">&nbsp;</td>
406
                      <td width="78%" class="vtable">
407
			<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
408
                      <strong>Deny unknown clients</strong><br>
409
                      If this is checked, only the clients defined below will get DHCP leases from this server. </td>
410
		      		  </tr>
411
                      <tr>
412
                        <td width="22%" valign="top" class="vncellreq">Subnet</td>
413
                        <td width="78%" class="vtable">
414
                          <?=gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']);?>
415
                        </td>
416
                      </tr>
417
                      <tr>
418
                        <td width="22%" valign="top" class="vncellreq">Subnet
419
                          mask</td>
420
                        <td width="78%" class="vtable">
421
                          <?=gen_subnet_mask($ifcfg['subnet']);?>
422
                        </td>
423
                      </tr>
424
                      <tr>
425
                        <td width="22%" valign="top" class="vncellreq">Available
426
                          range</td>
427
                        <td width="78%" class="vtable">
428
                          <?=long2ip(ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));?>
429
                          -
430
                          <?=long2ip(ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet']))); ?>
431
                        </td>
432
                      </tr>
433
					  <?php if($is_olsr_enabled): ?>
434
                      <tr>
435
                        <td width="22%" valign="top" class="vncellreq">Subnet Mask</td>
436
                        <td width="78%" class="vtable">
437
	                        <select name="netmask" class="formselect" id="netmask">
438
							<?php
439
							for ($i = 32; $i > 0; $i--) {
440
								if($i <> 31) {
441
									echo "<option value=\"{$i}\" ";
442
									if ($i == $pconfig['subnet']) echo "selected";
443
									echo ">" . $i . "</option>";
444
								}
445
							}
446
							?>
447
							</select>
448
                        </td>
449
                      </tr>
450
                      <?php endif; ?>
451
                      <tr>
452
                        <td width="22%" valign="top" class="vncellreq">Range</td>
453
                        <td width="78%" class="vtable">
454
                          <input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>">
455
                          &nbsp;to&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>">
456
			</td>
457
                      </tr>
458
                      <tr>
459
                        <td width="22%" valign="top" class="vncell">WINS servers</td>
460
                        <td width="78%" class="vtable">
461
                          <input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>"><br>
462
                          <input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>">
463
			</td>
464
                      </tr>
465
                      <tr>
466
                        <td width="22%" valign="top" class="vncell">DNS servers</td>
467
                        <td width="78%" class="vtable">
468
                          <input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
469
                          <input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
470
			  NOTE: leave blank to use the system default DNS servers.  This option is handy when your doing CARP+DHCP Failover, etc.
471
			</td>
472
                      </tr>
473
                     <tr>
474
                       <td width="22%" valign="top" class="vncell">Gateway</td>
475
                       <td width="78%" class="vtable">
476
                         <input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
477
			 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.
478
			</td>
479
                     </tr>
480
                      <tr>
481
                       <td width="22%" valign="top" class="vncell">Domain-Name</td>
482
                       <td width="78%" class="vtable">
483
                         <input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>"><br>
484
			 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.
485
			</td>
486
                     </tr>
487
                      <tr>
488
                       <td width="22%" valign="top" class="vncell">Domain-Searchlist</td>
489
                       <td width="78%" class="vtable">
490
                         <input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>"><br>
491
			 DNS-Searchlist: the DHCP server can serve a list of domains to be searched.
492
			</td>
493
                     </tr>                     
494
                      <tr>
495
                        <td width="22%" valign="top" class="vncell">Default lease time</td>
496
                        <td width="78%" class="vtable">
497
                          <input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
498
                          seconds<br>
499
                          This is used for clients that do not ask for a specific
500
                          expiration time.<br>
501
                          The default is 7200 seconds.
502
			</td>
503
                      </tr>
504
                      <tr>
505
                        <td width="22%" valign="top" class="vncell">Maximum lease time</td>
506
                        <td width="78%" class="vtable">
507
                          <input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
508
                          seconds<br>
509
                          This is the maximum lease time for clients that ask
510
                          for a specific expiration time.<br>
511
                          The default is 86400 seconds.
512
			</td>
513
                      </tr>
514
                      <tr>
515
                        <td width="22%" valign="top" class="vncell">Failover peer IP:</td>
516
                        <td width="78%" class="vtable">
517
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
518
				Leave blank to disable.  Enter the REAL address of the other machine.  Machines must be using CARP.
519
			</td>
520
		      </tr>
521
                      <tr>
522
                        <td width="22%" valign="top" class="vncell">Static ARP</td>
523
                        <td width="78%" class="vtable">
524
				<table>
525
					<tr>
526
						<td>
527
							<input valign="middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked"; ?>>&nbsp;
528
						</td>
529
						<td>
530
							<b>Enable Static ARP entries</b>
531
						</td>
532
					</tr>
533
					<tr>
534
						<td>
535
							&nbsp;
536
						</td>
537
						<td>
538
							<span class="red"><strong>Note:</strong></span> Only the machines listed below will be able to communicate with the firewall on this NIC.
539
						</td>
540
					</tr>
541
				</table>
542
			</td>
543
                      </tr>
544
                      <tr>
545
                        <td width="22%" valign="top" class="vncell">Dynamic DNS</td>
546
                        <td width="78%" class="vtable">
547
				<div id="showddnsbox">
548
					<input type="button" onClick="show_ddns_config()" value="Advanced"></input> - Show Dynamic DNS</a>
549
				</div>
550
				<div id="showddns" style="display:none">
551
					<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
552
					<b>Enable registration of DHCP client names in DNS.</b><br />
553
					<p>
554
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
555
					Note: Leave blank to disable dynamic DNS registration.<br />
556
					Enter the dynamic DNS domain which will be used to register client names in the DNS server.
557
				</div>
558
			</td>
559
		      </tr>
560
                      <tr>
561
                        <td width="22%" valign="top" class="vncell">NTP servers</td>
562
                        <td width="78%" class="vtable">
563
				<div id="showntpbox">
564
					<input type="button" onClick="show_ntp_config()" value="Advanced"></input> - Show NTP configuration</a>
565
				</div>
566
				<div id="showntp" style="display:none">
567
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
568
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
569
				</div>
570
			</td>
571
                      </tr>
572
                      <tr>
573
                        <td width="22%" valign="top" class="vncell">TFTP server</td>
574
                        <td width="78%" class="vtable">
575
				<div id="showtftpbox">
576
					<input type="button" onClick="show_tftp_config()" value="Advanced"></input> - Show TFTP configuration</a>
577
				</div>
578
				<div id="showtftp" style="display:none">
579
					<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
580
					Leave blank to disable.  Enter a full hostname or IP for the TFTP server.
581
				</div>
582
			</td>
583
                      </tr>
584
                      <tr>
585
                        <td width="22%" valign="top" class="vncell">LDAP URI</td>
586
                        <td width="78%" class="vtable">
587
				<div id="showldapbox">
588
					<input type="button" onClick="show_ldap_config()" value="Advanced"></input> - Show LDAP configuration</a>
589
				</div>
590
				<div id="showldap" style="display:none">
591
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
592
					Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com
593
				</div>
594
			</td>
595
                      </tr>
596
                      <tr>
597
                        <td width="22%" valign="top" class="vncell">Enable Network booting</td>
598
                        <td width="78%" class="vtable">
599
				<div id="shownetbootbox">
600
					<input type="button" onClick="show_netboot_config()" value="Advanced"></input> - Show Network booting</a>
601
				</div>
602
				<div id="shownetboot" style="display:none">
603
					<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
604
					<b>Enables network booting.</b>
605
					<p>
606
					Enter the IP of the <b>next-server</b>
607
					<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>">
608
					and the filename					
609
					<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
610
					Note: You need both a filename and a boot server configured for this to work!
611
				  <p>
612
					Enter the <b>root-path</b>-string
613
          <input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
614
          Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname
615
        </div>
616
			</td>
617
		                  </tr>
618
                      <tr>
619
                        <td width="22%" valign="top">&nbsp;</td>
620
                        <td width="78%">
621
                          <input name="if" type="hidden" value="<?=$if;?>">
622
                          <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
623
                        </td>
624
                      </tr>
625
                      <tr>
626
                        <td width="22%" valign="top">&nbsp;</td>
627
                        <td width="78%"> <p><span class="vexpl"><span class="red"><strong>Note:<br>
628
                            </strong></span>The DNS servers entered in <a href="system.php">System:
629
                            General setup</a> (or the <a href="services_dnsmasq.php">DNS
630
                            forwarder</a>, if enabled) </span><span class="vexpl">will
631
                            be assigned to clients by the DHCP server.<br>
632
                            <br>
633
                            The DHCP lease table can be viewed on the <a href="diag_dhcp_leases.php">Diagnostics:
634
                            DHCP leases</a> page.<br>
635
                            </span></p>
636
			</td>
637
                      </tr>
638
                    </table>
639
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
640
                <tr>
641
                  <td width="25%" class="listhdrr">MAC address</td>
642
                  <td width="15%" class="listhdrr">IP address</td>
643
				  <td width="20%" class="listhdrr">Hostname</td>
644
                  <td width="30%" class="listhdr">Description</td>
645
                  <td width="10%" class="list">
646
                    <table border="0" cellspacing="0" cellpadding="1">
647
                      <tr>
648
			<td valign="middle" width="17"></td>
649
                        <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>
650
                      </tr>
651
                    </table>
652
		  </td>
653
		</tr>
654
			  <?php if(is_array($a_maps)): ?>
655
			  <?php $i = 0; foreach ($a_maps as $mapent): ?>
656
			  <?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
657
                <tr>
658
                  <td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
659
                    <?=htmlspecialchars($mapent['mac']);?>
660
                  </td>
661
                  <td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
662
                    <?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
663
                  </td>
664
                  <td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
665
                    <?=htmlspecialchars($mapent['hostname']);?>&nbsp;
666
                  </td>	
667
                  <td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
668
                    <font color="#FFFFFF"><?=htmlspecialchars($mapent['descr']);?>&nbsp;</font>
669
                  </td>
670
                  <td valign="middle" nowrap class="list">
671
                    <table border="0" cellspacing="0" cellpadding="1">
672
                      <tr>
673
                        <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>
674
                        <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>
675
                      </tr>
676
                    </table>
677
                  </td>
678
                </tr>
679
		<?php endif; ?>
680
		<?php $i++; endforeach; ?>
681
		<?php endif; ?>
682
                <tr>
683
                  <td class="list" colspan="4"></td>
684
                  <td class="list">
685
                    <table border="0" cellspacing="0" cellpadding="1">
686
                      <tr>
687
			<td valign="middle" width="17"></td>
688
                        <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>
689
                      </tr>
690
                    </table>
691
                  </td>
692
                </tr>
693
              </table>
694
	</div>
695
    </td>
696
  </tr>
697
</table>
698
</form>
699
<script language="JavaScript">
700
<!--
701
enable_change(false);
702
//-->
703
</script>
704
<?php include("fend.inc"); ?>
705
</body>
706
</html>
(114-114/186)