Project

General

Profile

Download (31.5 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
$ifdescrs = get_configured_interface_with_descr();
57

    
58
foreach ($ifdescrs as $ifname => $ifdesc) {
59
	$oc = $config['interfaces'][$ifname];
60

    
61
	if (!is_ipaddr($oc['ipaddr']) && $is_olsr_enabled)
62
		$singleif_nostaticip = true;
63
	else if ($oc['if']) 
64
		$iflist[$ifname] = $ifdesc;
65
}
66

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

    
75
$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
76
$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
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

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

    
101

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

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

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

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