Project

General

Profile

Download (31.7 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
##|+PRIV
33
##|*IDENT=page-services-dhcpserver
34
##|*NAME=Services: DHCP server page
35
##|*DESCR=Allow access to the 'Services: DHCP server' page.
36
##|*MATCH=services_dhcp.php*
37
##|-PRIV
38

    
39

    
40
require("guiconfig.inc");
41

    
42
$if = $_GET['if'];
43
if ($_POST['if'])
44
	$if = $_POST['if'];
45

    
46
/* if OLSRD is enabled, allow WAN to house DHCP. */
47
if($config['installedpackages']['olsrd']) {
48
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
49
			if($olsrd['enable']) {
50
				$is_olsr_enabled = true;
51
				break;
52
			}
53
	}
54
}
55

    
56
if (!$_GET['if'])
57
	$savemsg = "<b>The DHCP Server can only be enabled on interfaces configured with static IP addresses.<p> The interfaces not configured with static ip will not be shown.</p></b>";
58

    
59
$iflist = get_configured_interface_with_descr();
60

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

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

    
100
$ifcfg = $config['interfaces'][$if];
101

    
102

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

    
108
$dhcrelay_enabled = false;
109
$dhcrelaycfg = $config['dhcrelay'];
110

    
111
if(is_array($dhcrelaycfg)) {
112
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
113
		if (isset($dhcrelayifconf['enable']) &&
114
			(($dhcrelayif == "lan") ||
115
			(isset($config['interfaces'][$dhcrelayif]['enable']) &&
116
			$config['interfaces'][$dhcrelayif]['if'] && (!link_int_to_bridge_interface($dhcrelayif)))))
117
			$dhcrelay_enabled = true;
118
	}
119
}
120

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

    
128
if ($_POST) {
129

    
130
	unset($input_errors);
131

    
132
	$pconfig = $_POST;
133

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

    
139
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
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
		if (!is_array($config['dhcpd'][$if]))
199
			$config['dhcpd'][$if] = array();
200
		if (!is_array($config['dhcpd'][$if]['range']))
201
			$config['dhcpd'][$if]['range'] = array();
202

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

    
214
		unset($config['dhcpd'][$if]['winsserver']);
215
		if ($_POST['wins1'])
216
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
217
		if ($_POST['wins2'])
218
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
219

    
220
		unset($config['dhcpd'][$if]['dnsserver']);
221
		if ($_POST['dns1'])
222
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
223
		if ($_POST['dns2'])
224
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
225

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

    
235
		unset($config['dhcpd'][$if]['ntpserver']);
236
		if ($_POST['ntp1'])
237
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
238
		if ($_POST['ntp2'])
239
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
240

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

    
248
		write_config();
249

    
250
		/* static arp configuration */
251
		interfaces_staticarp_configure($if);
252

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

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

    
295
$pgtitle = array("Services","DHCP server");
296
include("head.inc");
297

    
298
?>
299

    
300
<script type="text/javascript" language="JavaScript">
301

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

    
331
function show_ddns_config() {
332
	document.getElementById("showddnsbox").innerHTML='';
333
	aodiv = document.getElementById('showddns');
334
	aodiv.style.display = "block";
335
}
336

    
337
function show_ntp_config() {
338
	document.getElementById("showntpbox").innerHTML='';
339
	aodiv = document.getElementById('showntp');
340
	aodiv.style.display = "block";
341
}
342

    
343
function show_tftp_config() {
344
	document.getElementById("showtftpbox").innerHTML='';
345
	aodiv = document.getElementById('showtftp');
346
	aodiv.style.display = "block";
347
}
348

    
349
function show_ldap_config() {
350
	document.getElementById("showldapbox").innerHTML='';
351
	aodiv = document.getElementById('showldap');
352
	aodiv.style.display = "block";
353
}
354

    
355
function show_netboot_config() {
356
	document.getElementById("shownetbootbox").innerHTML='';
357
	aodiv = document.getElementById('shownetboot');
358
	aodiv.style.display = "block";
359
}
360

    
361
</script>
362

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