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
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
	/* if WAN is configured for anything other than static
54
	  IP, do not allow DHCP server to be configured. */
55
	if (!is_ipaddr($config['interfaces']['wan']['ipaddr']))
56
		$singleif_nostaticip = true;
57
	$iflist = array("wan" => strtoupper($g['wan_interface_name']));
58
}
59

    
60
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
61
	$oc = $config['interfaces']['opt' . $i];
62

    
63
	if (isset($oc['enable']) && $oc['if'] && (!$oc['bridge'])) {
64
		$iflist['opt' . $i] = $oc['descr'];
65
	}
66
}
67

    
68
/* set the starting interface */
69
if($config['interfaces']['lan']) {
70
	if (!$if || !isset($iflist[$if]))
71
		$if = "lan";
72
} else {
73
	$if = "wan";
74
}
75

    
76
$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
77
$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
78
$pconfig['deftime'] = $config['dhcpd'][$if]['defaultleasetime'];
79
$pconfig['maxtime'] = $config['dhcpd'][$if]['maxleasetime'];
80
$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
81
$pconfig['domain'] = $config['dhcpd'][$if]['domain'];
82
$pconfig['domainsearchlist'] = $config['dhcpd'][$if]['domainsearchlist'];
83
list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
84
list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
85
$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
86
$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
87
$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
88
$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
89
$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
90
list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
91
$pconfig['tftp'] = $config['dhcpd'][$if]['tftp'];
92
$pconfig['ldap'] = $config['dhcpd'][$if]['ldap'];
93
$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
94
$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
95
$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
96
$pconfig['rootpath'] = $config['dhcpd'][$if]['rootpath'];
97
$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
98
$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
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'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
117
			$dhcrelay_enabled = true;
118
	}
119
}
120

    
121
if (!is_array($config['dhcpd'][$if]['staticmap'])) {
122
	$config['dhcpd'][$if]['staticmap'] = array();
123
}
124
staticmaps_sort($if);
125
$a_maps = &$config['dhcpd'][$if]['staticmap'];
126

    
127
function is_inrange($test, $start, $end) {
128
	if ( (ip2long($test) < ip2long($end)) && (ip2long($test) > ip2long($start)) )
129
		return true;
130
	else
131
		return false;
132
}
133

    
134
if ($_POST) {
135

    
136
	unset($input_errors);
137

    
138
	$pconfig = $_POST;
139

    
140
	/* input validation */
141
	if ($_POST['enable']) {
142
		$reqdfields = explode(" ", "range_from range_to");
143
		$reqdfieldsn = explode(",", "Range begin,Range end");
144

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

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

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

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

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

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

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

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

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

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

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

    
249
		write_config();
250

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

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

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

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

    
299
?>
300

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

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

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

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

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

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

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

    
362
</script>
363

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