Project

General

Profile

Download (31.4 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
				$is_olsr_enabled = true;
43
				break;
44
			}
45
	}
46
}
47

    
48
$ifdescrs = get_configured_interface_with_descr();
49

    
50
foreach ($ifdescrs as $ifname => $ifdesc) {
51
	$oc = $config['interfaces'][$ifname];
52

    
53
	if (!is_ipaddr($oc['ipaddr']) && $is_olsr_enabled)
54
		$singleif_nostaticip = true;
55
	else if ($oc['if'] && (!$oc['bridge'])) 
56
		$iflist[$ifname] = $ifdesc['descr'];
57
}
58

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

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

    
91
$ifcfg = $config['interfaces'][$if];
92

    
93

    
94
/*   set the enabled flag which will tell us if DHCP relay is enabled
95
 *   on any interface.   We will use this to disable DHCP server since
96
 *   the two are not compatible with each other.
97
 */
98

    
99
$dhcrelay_enabled = false;
100
$dhcrelaycfg = $config['dhcrelay'];
101

    
102
if(is_array($dhcrelaycfg)) {
103
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
104
		if (isset($dhcrelayifconf['enable']) &&
105
			(($dhcrelayif == "lan") ||
106
			(isset($config['interfaces'][$dhcrelayif]['enable']) &&
107
			$config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
108
			$dhcrelay_enabled = true;
109
	}
110
}
111

    
112
if (!is_array($config['dhcpd'][$if]['staticmap'])) {
113
	$config['dhcpd'][$if]['staticmap'] = array();
114
}
115
staticmaps_sort($if);
116
$a_maps = &$config['dhcpd'][$if]['staticmap'];
117

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

    
125
if ($_POST) {
126

    
127
	unset($input_errors);
128

    
129
	$pconfig = $_POST;
130

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

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

    
175
		if (!$input_errors) {
176
			/* make sure the range lies within the current subnet */
177
			$subnet_start = (ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));
178
			$subnet_end = (ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])));
179

    
180
			if ((ip2long($_POST['range_from']) < $subnet_start) || (ip2long($_POST['range_from']) > $subnet_end) ||
181
			    (ip2long($_POST['range_to']) < $subnet_start) || (ip2long($_POST['range_to']) > $subnet_end)) {
182
				$input_errors[] = "The specified range lies outside of the current subnet.";
183
			}
184

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

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

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

    
206
		unset($config['dhcpd'][$if]['winsserver']);
207
		if ($_POST['wins1'])
208
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
209
		if ($_POST['wins2'])
210
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
211

    
212
		unset($config['dhcpd'][$if]['dnsserver']);
213
		if ($_POST['dns1'])
214
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
215
		if ($_POST['dns2'])
216
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
217

    
218
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
219
		$config['dhcpd'][$if]['domain'] = $_POST['domain'];
220
		$config['dhcpd'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
221
		$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
222
		$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
223
		$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
224
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
225
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
226

    
227
		unset($config['dhcpd'][$if]['ntpserver']);
228
		if ($_POST['ntp1'])
229
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
230
		if ($_POST['ntp2'])
231
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
232

    
233
		$config['dhcpd'][$if]['tftp'] = $_POST['tftp'];
234
		$config['dhcpd'][$if]['ldap'] = $_POST['ldap'];
235
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
236
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
237
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
238
		$config['dhcpd'][$if]['rootpath'] = $_POST['rootpath'];
239

    
240
		write_config();
241

    
242
		/* static arp configuration */
243
		interfaces_staticarp_configure($if);
244

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

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

    
287
$pgtitle = array("Services","DHCP server");
288
include("head.inc");
289

    
290
?>
291

    
292
<script type="text/javascript" language="JavaScript">
293

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

    
323
function show_ddns_config() {
324
	document.getElementById("showddnsbox").innerHTML='';
325
	aodiv = document.getElementById('showddns');
326
	aodiv.style.display = "block";
327
}
328

    
329
function show_ntp_config() {
330
	document.getElementById("showntpbox").innerHTML='';
331
	aodiv = document.getElementById('showntp');
332
	aodiv.style.display = "block";
333
}
334

    
335
function show_tftp_config() {
336
	document.getElementById("showtftpbox").innerHTML='';
337
	aodiv = document.getElementById('showtftp');
338
	aodiv.style.display = "block";
339
}
340

    
341
function show_ldap_config() {
342
	document.getElementById("showldapbox").innerHTML='';
343
	aodiv = document.getElementById('showldap');
344
	aodiv.style.display = "block";
345
}
346

    
347
function show_netboot_config() {
348
	document.getElementById("shownetbootbox").innerHTML='';
349
	aodiv = document.getElementById('shownetboot');
350
	aodiv.style.display = "block";
351
}
352

    
353
</script>
354

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