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($config['interfaces']['lan']) {
50
	if(!$iflist)
51
		$iflist = array("lan" => "LAN");
52
} else {
53
	$iflist = array("wan" => strtoupper($g['wan_interface_name']));
54
}
55

    
56
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
57
	$oc = $config['interfaces']['opt' . $i];
58

    
59
	if (isset($oc['enable']) && $oc['if'] && (!$oc['bridge'])) {
60
		$iflist['opt' . $i] = $oc['descr'];
61
	}
62
}
63

    
64
/* set the starting interface */
65
if($config['interfaces']['lan']) {
66
	if (!$if || !isset($iflist[$if]))
67
		$if = "lan";
68
} else {
69
	$if = "wan";
70
}
71

    
72
$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
73
$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
74
$pconfig['deftime'] = $config['dhcpd'][$if]['defaultleasetime'];
75
$pconfig['maxtime'] = $config['dhcpd'][$if]['maxleasetime'];
76
$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
77
$pconfig['domain'] = $config['dhcpd'][$if]['domain'];
78
$pconfig['domainsearchlist'] = $config['dhcpd'][$if]['domainsearchlist'];
79
list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
80
list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
81
$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
82
$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
83
$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
84
$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
85
$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
86
list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
87
$pconfig['tftp'] = $config['dhcpd'][$if]['tftp'];
88
$pconfig['ldap'] = $config['dhcpd'][$if]['ldap'];
89
$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
90
$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
91
$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
92
$pconfig['rootpath'] = $config['dhcpd'][$if]['rootpath'];
93
$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
94
$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
95

    
96
$ifcfg = $config['interfaces'][$if];
97

    
98

    
99
/*   set the enabled flag which will tell us if DHCP relay is enabled
100
 *   on any interface.   We will use this to disable DHCP server since
101
 *   the two are not compatible with each other.
102
 */
103

    
104
$dhcrelay_enabled = false;
105
$dhcrelaycfg = $config['dhcrelay'];
106

    
107
if(is_array($dhcrelaycfg)) {
108
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
109
		if (isset($dhcrelayifconf['enable']) &&
110
			(($dhcrelayif == "lan") ||
111
			(isset($config['interfaces'][$dhcrelayif]['enable']) &&
112
			$config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
113
			$dhcrelay_enabled = true;
114
	}
115
}
116

    
117
if (!is_array($config['dhcpd'][$if]['staticmap'])) {
118
	$config['dhcpd'][$if]['staticmap'] = array();
119
}
120
staticmaps_sort($if);
121
$a_maps = &$config['dhcpd'][$if]['staticmap'];
122

    
123
function is_inrange($test, $start, $end) {
124
	if ( (ip2long($test) < ip2long($end)) && (ip2long($test) > ip2long($start)) )
125
		return true;
126
	else
127
		return false;
128
}
129

    
130
if ($_POST) {
131

    
132
	unset($input_errors);
133

    
134
	$pconfig = $_POST;
135

    
136
	/* input validation */
137
	if ($_POST['enable']) {
138
		$reqdfields = explode(" ", "range_from range_to");
139
		$reqdfieldsn = explode(",", "Range begin,Range end");
140

    
141
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
142
		
143
		if (($_POST['range_from'] && !is_ipaddr($_POST['range_from']))) {
144
			$input_errors[] = "A valid range must be specified.";
145
		}
146
		if (($_POST['range_to'] && !is_ipaddr($_POST['range_to']))) {
147
			$input_errors[] = "A valid range must be specified.";
148
		}
149
		if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
150
			$input_errors[] = "A valid IP address must be specified for the gateway.";
151
		}
152
		if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2']))) {
153
			$input_errors[] = "A valid IP address must be specified for the primary/secondary WINS servers.";
154
		}
155
		if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2']))) {
156
			$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS servers.";
157
		}
158
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60))) {
159
			$input_errors[] = "The default lease time must be at least 60 seconds.";
160
		}
161
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime']))) {
162
			$input_errors[] = "The maximum lease time must be at least 60 seconds and higher than the default lease time.";
163
		}
164
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
165
			$input_errors[] = "A valid domain name must be specified for the dynamic DNS registration.";
166
		}
167
		if (($_POST['ntp1'] && !is_ipaddr($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddr($_POST['ntp2']))) {
168
			$input_errors[] = "A valid IP address must be specified for the primary/secondary NTP servers.";
169
		}
170
		if (($_POST['domain'] && !is_domain($_POST['domain']))) {
171
			$input_errors[] = "A valid domain name must be specified for the DNS domain.";
172
    }
173
		if (($_POST['tftp'] && !is_ipaddr($_POST['tftp']))) {
174
			$input_errors[] = "A valid IP address must be specified for the tftp server.";
175
		}
176
		if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver']))) {
177
			$input_errors[] = "A valid IP address must be specified for the network boot server.";
178
		}
179

    
180
		if (!$input_errors) {
181
			/* make sure the range lies within the current subnet */
182
			$subnet_start = (ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));
183
			$subnet_end = (ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])));
184

    
185
			if ((ip2long($_POST['range_from']) < $subnet_start) || (ip2long($_POST['range_from']) > $subnet_end) ||
186
			    (ip2long($_POST['range_to']) < $subnet_start) || (ip2long($_POST['range_to']) > $subnet_end)) {
187
				$input_errors[] = "The specified range lies outside of the current subnet.";
188
			}
189

    
190
			if (ip2long($_POST['range_from']) > ip2long($_POST['range_to']))
191
				$input_errors[] = "The range is invalid (first element higher than second element).";
192

    
193
			/* make sure that the DHCP Relay isn't enabled on this interface */
194
			if (isset($config['dhcrelay'][$if]['enable']))
195
				$input_errors[] = "You must disable the DHCP relay on the {$iflist[$if]} interface before enabling the DHCP server.";
196
		}
197
	}
198

    
199
	if (!$input_errors) {
200
		$config['dhcpd'][$if]['range']['from'] = $_POST['range_from'];
201
		$config['dhcpd'][$if]['range']['to'] = $_POST['range_to'];
202
		$config['dhcpd'][$if]['defaultleasetime'] = $_POST['deftime'];
203
		$config['dhcpd'][$if]['maxleasetime'] = $_POST['maxtime'];
204
		$config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
205
		$previous = $config['dhcpd'][$if]['failover_peerip'];
206
		if($previous <> $_POST['failover_peerip']) {
207
			mwexec("rm -rf /var/dhcpd/var/db/*");
208
		}
209
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
210

    
211
		unset($config['dhcpd'][$if]['winsserver']);
212
		if ($_POST['wins1'])
213
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
214
		if ($_POST['wins2'])
215
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
216

    
217
		unset($config['dhcpd'][$if]['dnsserver']);
218
		if ($_POST['dns1'])
219
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
220
		if ($_POST['dns2'])
221
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
222

    
223
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
224
		$config['dhcpd'][$if]['domain'] = $_POST['domain'];
225
		$config['dhcpd'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
226
		$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
227
		$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
228
		$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
229
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
230
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
231

    
232
		unset($config['dhcpd'][$if]['ntpserver']);
233
		if ($_POST['ntp1'])
234
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
235
		if ($_POST['ntp2'])
236
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
237

    
238
		$config['dhcpd'][$if]['tftp'] = $_POST['tftp'];
239
		$config['dhcpd'][$if]['ldap'] = $_POST['ldap'];
240
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
241
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
242
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
243
		$config['dhcpd'][$if]['rootpath'] = $_POST['rootpath'];
244

    
245
		write_config();
246

    
247
		/* static arp configuration */
248
		interfaces_staticarp_configure($if);
249

    
250
		$retval = 0;
251
		$retvaldhcp = 0;
252
		$retvaldns = 0;
253
		config_lock();
254
		/* dnsmasq_configure calls dhcpd_configure */
255
		/* no need to restart dhcpd twice */
256
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
257
			$retvaldns = services_dnsmasq_configure();
258
			if ($retvaldns == 0) {
259
				if (file_exists($d_hostsdirty_path))
260
					unlink($d_hostsdirty_path);
261
				if (file_exists($d_staticmapsdirty_path))
262
					unlink($d_staticmapsdirty_path);
263
			}					
264
		} else {
265
			$retvaldhcp = services_dhcpd_configure();	
266
			if ($retvaldhcp == 0) {
267
				if (file_exists($d_staticmapsdirty_path))
268
					unlink($d_staticmapsdirty_path);
269
			}
270
		}	
271
		config_unlock();
272
		if($retvaldhcp == 1 || $retvaldns == 1)
273
			$retval = 1;
274
		$savemsg = get_std_save_message($retval);
275
	}
276
}
277

    
278
if ($_GET['act'] == "del") {
279
	if ($a_maps[$_GET['id']]) {
280
		unset($a_maps[$_GET['id']]);
281
		write_config();
282
		if(isset($config['dhcpd'][$if]['enable'])) {
283
			touch($d_staticmapsdirty_path);
284
			if (isset($config['dnsmasq']['regdhcpstatic']))
285
				touch($d_hostsdirty_path);
286
		}
287
		header("Location: services_dhcp.php?if={$if}");
288
		exit;
289
	}
290
}
291

    
292
$pgtitle = array("Services","DHCP server");
293
include("head.inc");
294

    
295
?>
296

    
297
<script type="text/javascript" language="JavaScript">
298

    
299
function enable_change(enable_over) {
300
	var endis;
301
	endis = !(document.iform.enable.checked || enable_over);
302
	document.iform.range_from.disabled = endis;
303
	document.iform.range_to.disabled = endis;
304
	document.iform.wins1.disabled = endis;
305
	document.iform.wins2.disabled = endis;
306
	document.iform.dns1.disabled = endis;
307
	document.iform.dns2.disabled = endis;
308
	document.iform.deftime.disabled = endis;
309
	document.iform.maxtime.disabled = endis;
310
	document.iform.gateway.disabled = endis;
311
	document.iform.failover_peerip.disabled = endis;
312
	document.iform.domain.disabled = endis;
313
	document.iform.domainsearchlist.disabled = endis;
314
	document.iform.staticarp.disabled = endis;
315
	document.iform.ddnsdomain.disabled = endis;
316
	document.iform.ddnsupdate.disabled = endis;
317
	document.iform.ntp1.disabled = endis;
318
	document.iform.ntp2.disabled = endis;
319
	document.iform.tftp.disabled = endis;
320
	document.iform.ldap.disabled = endis;
321
	document.iform.netboot.disabled = endis;
322
	document.iform.nextserver.disabled = endis;
323
	document.iform.filename.disabled = endis;
324
	document.iform.rootpath.disabled = endis;
325
	document.iform.denyunknown.disabled = endis;
326
}
327

    
328
function show_ddns_config() {
329
	document.getElementById("showddnsbox").innerHTML='';
330
	aodiv = document.getElementById('showddns');
331
	aodiv.style.display = "block";
332
}
333

    
334
function show_ntp_config() {
335
	document.getElementById("showntpbox").innerHTML='';
336
	aodiv = document.getElementById('showntp');
337
	aodiv.style.display = "block";
338
}
339

    
340
function show_tftp_config() {
341
	document.getElementById("showtftpbox").innerHTML='';
342
	aodiv = document.getElementById('showtftp');
343
	aodiv.style.display = "block";
344
}
345

    
346
function show_ldap_config() {
347
	document.getElementById("showldapbox").innerHTML='';
348
	aodiv = document.getElementById('showldap');
349
	aodiv.style.display = "block";
350
}
351

    
352
function show_netboot_config() {
353
	document.getElementById("shownetbootbox").innerHTML='';
354
	aodiv = document.getElementById('shownetboot');
355
	aodiv.style.display = "block";
356
}
357

    
358
</script>
359

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