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
require("guiconfig.inc");
40

    
41
if(!$g['services_dhcp_server_enable']) {
42
	Header("Location: /");
43
	exit;
44
}
45

    
46
$if = $_GET['if'];
47
if ($_POST['if'])
48
	$if = $_POST['if'];
49

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

    
60
if (!$_GET['if'])
61
	$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>";
62

    
63
$iflist = get_configured_interface_with_descr();
64

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

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

    
104
$ifcfgip = get_interface_ip($if);
105
$ifcfgsn = get_interface_subnet($if);
106

    
107

    
108
/*   set the enabled flag which will tell us if DHCP relay is enabled
109
 *   on any interface.   We will use this to disable DHCP server since
110
 *   the two are not compatible with each other.
111
 */
112

    
113
$dhcrelay_enabled = false;
114
$dhcrelaycfg = $config['dhcrelay'];
115

    
116
if(is_array($dhcrelaycfg)) {
117
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
118
		if (isset($dhcrelayifconf['enable']) &&
119
			(($dhcrelayif == "lan") ||
120
			(isset($config['interfaces'][$dhcrelayif]['enable']) &&
121
			$config['interfaces'][$dhcrelayif]['if'] && (!link_interface_to_bridge($dhcrelayif)))))
122
			$dhcrelay_enabled = true;
123
	}
124
}
125

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

    
133
if ($_POST) {
134

    
135
	unset($input_errors);
136

    
137
	$pconfig = $_POST;
138

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

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

    
183
		if (!$input_errors) {
184
			/* make sure the range lies within the current subnet */
185
			$subnet_start = (ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn));
186
			$subnet_end = (ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn)));
187

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

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

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

    
202
	if (!$input_errors) {
203
		if (!is_array($config['dhcpd'][$if]))
204
			$config['dhcpd'][$if] = array();
205
		if (!is_array($config['dhcpd'][$if]['range']))
206
			$config['dhcpd'][$if]['range'] = array();
207

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

    
219
		unset($config['dhcpd'][$if]['winsserver']);
220
		if ($_POST['wins1'])
221
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
222
		if ($_POST['wins2'])
223
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
224

    
225
		unset($config['dhcpd'][$if]['dnsserver']);
226
		if ($_POST['dns1'])
227
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
228
		if ($_POST['dns2'])
229
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
230

    
231
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
232
		$config['dhcpd'][$if]['domain'] = $_POST['domain'];
233
		$config['dhcpd'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
234
		$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
235
		$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
236
		$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
237
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
238
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
239

    
240
		unset($config['dhcpd'][$if]['ntpserver']);
241
		if ($_POST['ntp1'])
242
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
243
		if ($_POST['ntp2'])
244
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
245

    
246
		$config['dhcpd'][$if]['tftp'] = $_POST['tftp'];
247
		$config['dhcpd'][$if]['ldap'] = $_POST['ldap'];
248
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
249
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
250
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
251
		$config['dhcpd'][$if]['rootpath'] = $_POST['rootpath'];
252

    
253
		write_config();
254

    
255
		/* static arp configuration */
256
		interfaces_staticarp_configure($if);
257

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

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

    
300
$pgtitle = array("Services","DHCP server");
301
include("head.inc");
302

    
303
?>
304

    
305
<script type="text/javascript" language="JavaScript">
306

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

    
336
function show_ddns_config() {
337
	document.getElementById("showddnsbox").innerHTML='';
338
	aodiv = document.getElementById('showddns');
339
	aodiv.style.display = "block";
340
}
341

    
342
function show_ntp_config() {
343
	document.getElementById("showntpbox").innerHTML='';
344
	aodiv = document.getElementById('showntp');
345
	aodiv.style.display = "block";
346
}
347

    
348
function show_tftp_config() {
349
	document.getElementById("showtftpbox").innerHTML='';
350
	aodiv = document.getElementById('showtftp');
351
	aodiv.style.display = "block";
352
}
353

    
354
function show_ldap_config() {
355
	document.getElementById("showldapbox").innerHTML='';
356
	aodiv = document.getElementById('showldap');
357
	aodiv.style.display = "block";
358
}
359

    
360
function show_netboot_config() {
361
	document.getElementById("shownetbootbox").innerHTML='';
362
	aodiv = document.getElementById('shownetboot');
363
	aodiv.style.display = "block";
364
}
365

    
366
</script>
367

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