Project

General

Profile

Download (29.2 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
/*  Fix failover DHCP problem 
35
 *  http://article.gmane.org/gmane.comp.security.firewalls.pfsense.support/18749
36
 */
37
ini_set("memory_limit","64M");
38

    
39
/* This function will remove entries from dhcpd.leases that would otherwise
40
 * overlap with static DHCP reservations. If we don't clean these out,
41
 * then DHCP will print a warning in the logs about a duplicate lease
42
 */
43
function dhcp_clean_leases() {
44
	global $g, $config;
45
	$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
46
	if (!file_exists($leasesfile))
47
		return;
48
	/* Build list of static MACs */
49
	$staticmacs = array();
50
	foreach($config['interfaces'] as $ifname => $ifarr)
51
		if (is_array($config['dhcpd'][$ifname]['staticmap']))
52
			foreach($config['dhcpd'][$ifname]['staticmap'] as $static)
53
				$staticmacs[] = $static['mac'];
54
	/* Read existing leases */
55
	$leases_contents = explode("\n", file_get_contents($leasesfile));
56
	$newleases_contents = array();
57
	$i=0;
58
	while ($i < count($leases_contents)) {
59
		/* Find a lease definition */
60
		if (substr($leases_contents[$i], 0, 6) == "lease ") {
61
			$templease = array();
62
			$thismac = "";
63
			/* Read to the end of the lease declaration */
64
			do {
65
				if (substr($leases_contents[$i], 0, 20) == "  hardware ethernet ")
66
					$thismac = substr($leases_contents[$i], 20, 17);
67
				$templease[] = $leases_contents[$i];
68
				$i++;
69
			} while ($leases_contents[$i-1] != "}");
70
			/* Check for a matching MAC address and if not present, keep it. */
71
			if (! in_array($thismac, $staticmacs))
72
				$newleases_contents = array_merge($newleases_contents, $templease);
73
		} else {
74
			/* It's a line we want to keep, copy it over. */
75
			$newleases_contents[] = $leases_contents[$i];
76
			$i++;
77
		}
78
	}
79
	/* Write out the new leases file */
80
	$fd = fopen($leasesfile, 'w');
81
	fwrite($fd, implode("\n", $newleases_contents));
82
	fclose($fd);
83
}
84

    
85
$if = $_GET['if'];
86
if ($_POST['if'])
87
	$if = $_POST['if'];
88

    
89
/* if OLSRD is enabled, allow WAN to house DHCP. */
90
if($config['installedpackages']['olsrd']) {
91
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
92
			if($olsrd['enable']) {
93
				$iflist = array("lan" => "LAN", "wan" => "WAN");
94
				$is_olsr_enabled = true;
95
				break;
96
			}
97
	}
98
}
99

    
100
if(!$iflist)
101
	$iflist = array("lan" => "LAN");
102

    
103
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
104
	$oc = $config['interfaces']['opt' . $i];
105

    
106
	if (isset($oc['enable']) && $oc['if'] && (!$oc['bridge'])) {
107
		$iflist['opt' . $i] = $oc['descr'];
108
	}
109
}
110

    
111
if (!$if || !isset($iflist[$if]))
112
	$if = "lan";
113

    
114
$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
115
$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
116
$pconfig['deftime'] = $config['dhcpd'][$if]['defaultleasetime'];
117
$pconfig['maxtime'] = $config['dhcpd'][$if]['maxleasetime'];
118
$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
119
list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
120
list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
121
$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
122
$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
123
$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
124
$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
125
$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
126
list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
127
$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
128
$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
129
$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
130
$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
131
$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
132

    
133
$ifcfg = $config['interfaces'][$if];
134

    
135
/*   set the enabled flag which will tell us if DHCP relay is enabled
136
 *   on any interface.   We will use this to disable DHCP server since
137
 *   the two are not compatible with each other.
138
 */
139

    
140
$dhcrelay_enabled = false;
141
$dhcrelaycfg = $config['dhcrelay'];
142

    
143
if(is_array($dhcrelaycfg)) {
144
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
145
		if (isset($dhcrelayifconf['enable']) &&
146
			(($dhcrelayif == "lan") ||
147
			(isset($config['interfaces'][$dhcrelayif]['enable']) &&
148
			$config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
149
			$dhcrelay_enabled = true;
150
	}
151
}
152

    
153

    
154
if (!is_array($config['dhcpd'][$if]['staticmap'])) {
155
	$config['dhcpd'][$if]['staticmap'] = array();
156
}
157
staticmaps_sort($if);
158
$a_maps = &$config['dhcpd'][$if]['staticmap'];
159

    
160
function is_inrange($test, $start, $end) {
161
	if ( (ip2long($test) < ip2long($end)) && (ip2long($test) > ip2long($start)) )
162
		return true;
163
	else
164
		return false;
165
}
166

    
167
if ($_POST) {
168

    
169
	unset($input_errors);
170

    
171
	$pconfig = $_POST;
172

    
173
	/* input validation */
174
	if ($_POST['enable']) {
175
		$reqdfields = explode(" ", "range_from range_to");
176
		$reqdfieldsn = explode(",", "Range begin,Range end");
177

    
178
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
179

    
180
		foreach($a_maps as $mapent) {
181
			if(is_inrange($mapent['ipaddr'], $_POST['range_from'], $_POST['range_to'])) {
182
				$input_errors[] = "{$mapent['ipaddr']} is inside the range you specified.";
183
			}
184

    
185
		}
186

    
187
		if (($_POST['range_from'] && !is_ipaddr($_POST['range_from']))) {
188
			$input_errors[] = "A valid range must be specified.";
189
		}
190
		if (($_POST['range_to'] && !is_ipaddr($_POST['range_to']))) {
191
			$input_errors[] = "A valid range must be specified.";
192
		}
193
		if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
194
			$input_errors[] = "A valid IP address must be specified for the gateway.";
195
		}
196
		if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2']))) {
197
			$input_errors[] = "A valid IP address must be specified for the primary/secondary WINS servers.";
198
		}
199
		if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2']))) {
200
			$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS servers.";
201
		}
202
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60))) {
203
			$input_errors[] = "The default lease time must be at least 60 seconds.";
204
		}
205
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime']))) {
206
			$input_errors[] = "The maximum lease time must be at least 60 seconds and higher than the default lease time.";
207
		}
208
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
209
			$input_errors[] = "A valid domain name must be specified for the dynamic DNS registration.";
210
		}
211
		if (($_POST['ntp1'] && !is_ipaddr($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddr($_POST['ntp2']))) {
212
			$input_errors[] = "A valid IP address must be specified for the primary/secondary NTP servers.";
213
		}
214
		if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver']))) {
215
			$input_errors[] = "A valid IP address must be specified for the network boot server.";
216
		}
217

    
218

    
219
		if (!$input_errors) {
220
			/* make sure the range lies within the current subnet */
221
			$subnet_start = (ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));
222
			$subnet_end = (ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])));
223

    
224
			if ((ip2long($_POST['range_from']) < $subnet_start) || (ip2long($_POST['range_from']) > $subnet_end) ||
225
			    (ip2long($_POST['range_to']) < $subnet_start) || (ip2long($_POST['range_to']) > $subnet_end)) {
226
				$input_errors[] = "The specified range lies outside of the current subnet.";
227
			}
228

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

    
232
			/* make sure that the DHCP Relay isn't enabled on this interface */
233
			if (isset($config['dhcrelay'][$if]['enable']))
234
				$input_errors[] = "You must disable the DHCP relay on the {$iflist[$if]} interface before enabling the DHCP server.";
235
		}
236
	}
237

    
238
	if (!$input_errors) {
239
		$config['dhcpd'][$if]['range']['from'] = $_POST['range_from'];
240
		$config['dhcpd'][$if]['range']['to'] = $_POST['range_to'];
241
		$config['dhcpd'][$if]['defaultleasetime'] = $_POST['deftime'];
242
		$config['dhcpd'][$if]['maxleasetime'] = $_POST['maxtime'];
243
		$config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
244
		$previous = $config['dhcpd'][$if]['failover_peerip'];
245
		if($previous <> $_POST['failover_peerip']) {
246
			mwexec("rm -rf /var/dhcpd/var/db/*");
247
		}
248
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
249

    
250
		unset($config['dhcpd'][$if]['winsserver']);
251
		if ($_POST['wins1'])
252
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
253
		if ($_POST['wins2'])
254
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
255

    
256
		unset($config['dhcpd'][$if]['dnsserver']);
257
		if ($_POST['dns1'])
258
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
259
		if ($_POST['dns2'])
260
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
261

    
262
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
263
		$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
264
		$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
265
		$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
266
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
267
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
268

    
269
		unset($config['dhcpd'][$if]['ntpserver']);
270
		if ($_POST['ntp1'])
271
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
272
		if ($_POST['ntp2'])
273
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
274

    
275
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
276
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
277
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
278

    
279
		write_config();
280

    
281
		/* static arp configuration */
282
		interfaces_staticarp_configure($if);
283

    
284
		$retval = 0;
285
		$retvaldhcp = 0;
286
		$retvaldns = 0;
287
		config_lock();
288
		/* Stop DHCP so we can cleanup leases */
289
		killbyname("dhcpd");
290
		dhcp_clean_leases();
291
		/* dnsmasq_configure calls dhcpd_configure */
292
		/* no need to restart dhcpd twice */
293
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
294
			$retvaldns = services_dnsmasq_configure();
295
			if ($retvaldns == 0) {
296
				if (file_exists($d_hostsdirty_path))
297
					unlink($d_hostsdirty_path);
298
				if (file_exists($d_staticmapsdirty_path))
299
					unlink($d_staticmapsdirty_path);
300
			}					
301
		} else {
302
			$retvaldhcp = services_dhcpd_configure();	
303
			if ($retvaldhcp == 0) {
304
				if (file_exists($d_staticmapsdirty_path))
305
					unlink($d_staticmapsdirty_path);
306
			}
307
		}	
308
		config_unlock();
309
		if($retvaldhcp == 1 || $retvaldns == 1)
310
			$retval = 1;
311
		$savemsg = get_std_save_message($retval);
312
	}
313
}
314

    
315
if ($_GET['act'] == "del") {
316
	if ($a_maps[$_GET['id']]) {
317
		unset($a_maps[$_GET['id']]);
318
		write_config();
319
		if(isset($config['dhcpd'][$if]['enable'])) {
320
			touch($d_staticmapsdirty_path);
321
			if (isset($config['dnsmasq']['regdhcpstatic']))
322
				touch($d_hostsdirty_path);
323
		}
324
		header("Location: services_dhcp.php?if={$if}");
325
		exit;
326
	}
327
}
328

    
329
$pgtitle = "Services: DHCP server";
330
include("head.inc");
331

    
332
?>
333

    
334
<script type="text/javascript" language="JavaScript">
335

    
336
function enable_change(enable_over) {
337
	var endis;
338
	endis = !(document.iform.enable.checked || enable_over);
339
	document.iform.range_from.disabled = endis;
340
	document.iform.range_to.disabled = endis;
341
	document.iform.wins1.disabled = endis;
342
	document.iform.wins2.disabled = endis;
343
	document.iform.dns1.disabled = endis;
344
	document.iform.dns2.disabled = endis;
345
	document.iform.deftime.disabled = endis;
346
	document.iform.maxtime.disabled = endis;
347
	document.iform.gateway.disabled = endis;
348
	document.iform.failover_peerip.disabled = endis;
349
	document.iform.staticarp.disabled = endis;
350
	document.iform.ddnsdomain.disabled = endis;
351
	document.iform.ddnsupdate.disabled = endis;
352
	document.iform.ntp1.disabled = endis;
353
	document.iform.ntp2.disabled = endis;
354
	document.iform.netboot.disabled = endis;
355
	document.iform.nextserver.disabled = endis;
356
	document.iform.filename.disabled = endis;
357
	document.iform.denyunknown.disabled = endis;
358
}
359

    
360
function show_ddns_config() {
361
	document.getElementById("showddnsbox").innerHTML='';
362
	aodiv = document.getElementById('showddns');
363
	aodiv.style.display = "block";
364
}
365

    
366
function show_ntp_config() {
367
	document.getElementById("showntpbox").innerHTML='';
368
	aodiv = document.getElementById('showntp');
369
	aodiv.style.display = "block";
370
}
371

    
372
function show_netboot_config() {
373
	document.getElementById("shownetbootbox").innerHTML='';
374
	aodiv = document.getElementById('shownetboot');
375
	aodiv.style.display = "block";
376
}
377

    
378
</script>
379

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