Project

General

Profile

Download (27.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_dhcp.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
require("guiconfig.inc");
33

    
34
$if = $_GET['if'];
35
if ($_POST['if'])
36
	$if = $_POST['if'];
37

    
38
/* if OLSRD is enabled, allow WAN to house DHCP. */
39
if($config['installedpackages']['olsrd']) {
40
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
41
			if($olsrd['enable']) {
42
				$iflist = array("lan" => "LAN", "wan" => "WAN");
43
				$is_olsr_enabled = true;
44
				break;
45
			}
46
	}
47
}
48

    
49
if(!$iflist)
50
	$iflist = array("lan" => "LAN");
51

    
52
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
53
	$oc = $config['interfaces']['opt' . $i];
54

    
55
	if (isset($oc['enable']) && $oc['if'] && (!$oc['bridge'])) {
56
		$iflist['opt' . $i] = $oc['descr'];
57
	}
58
}
59

    
60
if (!$if || !isset($iflist[$if]))
61
	$if = "lan";
62

    
63
$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
64
$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
65
$pconfig['deftime'] = $config['dhcpd'][$if]['defaultleasetime'];
66
$pconfig['maxtime'] = $config['dhcpd'][$if]['maxleasetime'];
67
$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
68
list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
69
list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
70
$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
71
$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
72
$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
73
$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
74
$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
75
list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
76
$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
77
$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
78
$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
79
$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
80
$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
81

    
82
$ifcfg = $config['interfaces'][$if];
83

    
84
/*   set the enabled flag which will tell us if DHCP relay is enabled
85
 *   on any interface.   We will use this to disable DHCP server since
86
 *   the two are not compatible with each other.
87
 */
88

    
89
$dhcrelay_enabled = false;
90
$dhcrelaycfg = $config['dhcrelay'];
91

    
92
if(is_array($dhcrelaycfg)) {
93
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
94
		if (isset($dhcrelayifconf['enable']) &&
95
			(($dhcrelayif == "lan") ||
96
			(isset($config['interfaces'][$dhcrelayif]['enable']) &&
97
			$config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
98
			$dhcrelay_enabled = true;
99
	}
100
}
101

    
102

    
103
if (!is_array($config['dhcpd'][$if]['staticmap'])) {
104
	$config['dhcpd'][$if]['staticmap'] = array();
105
}
106
staticmaps_sort($if);
107
$a_maps = &$config['dhcpd'][$if]['staticmap'];
108

    
109
function is_inrange($test, $start, $end) {
110
	if ( (ip2long($test) < ip2long($end)) && (ip2long($test) > ip2long($start)) )
111
		return true;
112
	else
113
		return false;
114
}
115

    
116
if ($_POST) {
117

    
118
	unset($input_errors);
119

    
120
	$pconfig = $_POST;
121

    
122
	/* input validation */
123
	if ($_POST['enable']) {
124
		$reqdfields = explode(" ", "range_from range_to");
125
		$reqdfieldsn = explode(",", "Range begin,Range end");
126

    
127
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
128

    
129
		foreach($a_maps as $mapent) {
130
			if(is_inrange($mapent['ipaddr'], $_POST['range_from'], $_POST['range_to'])) {
131
				$input_errors[] = "{$mapent['ipaddr']} is inside the range you specified.";
132
			}
133

    
134
		}
135

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

    
167

    
168
		if (!$input_errors) {
169
			/* make sure the range lies within the current subnet */
170
			$subnet_start = (ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));
171
			$subnet_end = (ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])));
172

    
173
			if ((ip2long($_POST['range_from']) < $subnet_start) || (ip2long($_POST['range_from']) > $subnet_end) ||
174
			    (ip2long($_POST['range_to']) < $subnet_start) || (ip2long($_POST['range_to']) > $subnet_end)) {
175
				$input_errors[] = "The specified range lies outside of the current subnet.";
176
			}
177

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

    
181
			/* make sure that the DHCP Relay isn't enabled on this interface */
182
			if (isset($config['dhcrelay'][$if]['enable']))
183
				$input_errors[] = "You must disable the DHCP relay on the {$iflist[$if]} interface before enabling the DHCP server.";
184
		}
185
	}
186

    
187
	if (!$input_errors) {
188
		$config['dhcpd'][$if]['range']['from'] = $_POST['range_from'];
189
		$config['dhcpd'][$if]['range']['to'] = $_POST['range_to'];
190
		$config['dhcpd'][$if]['defaultleasetime'] = $_POST['deftime'];
191
		$config['dhcpd'][$if]['maxleasetime'] = $_POST['maxtime'];
192
		$config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
193
		$previous = $config['dhcpd'][$if]['failover_peerip'];
194
		if($previous <> $_POST['failover_peerip']) {
195
			mwexec("rm -rf /var/dhcpd/var/db/*");
196
		}
197
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
198

    
199
		unset($config['dhcpd'][$if]['winsserver']);
200
		if ($_POST['wins1'])
201
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
202
		if ($_POST['wins2'])
203
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
204

    
205
		unset($config['dhcpd'][$if]['dnsserver']);
206
		if ($_POST['dns1'])
207
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
208
		if ($_POST['dns2'])
209
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
210

    
211
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
212
		$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
213
		$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
214
		$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
215
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
216
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
217

    
218
		unset($config['dhcpd'][$if]['ntpserver']);
219
		if ($_POST['ntp1'])
220
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
221
		if ($_POST['ntp2'])
222
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
223

    
224
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
225
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
226
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
227

    
228
		write_config();
229

    
230
		/* static arp configuration */
231
		interfaces_staticarp_configure($if);
232

    
233
		$retval = 0;
234
		$retvaldhcp = 0;
235
		$retvaldns = 0;
236
		config_lock();
237
		/* dnsmasq_configure calls dhcpd_configure */
238
		/* no need to restart dhcpd twice */
239
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
240
			$retvaldns = services_dnsmasq_configure();
241
			if ($retvaldns == 0) {
242
				if (file_exists($d_hostsdirty_path))
243
					unlink($d_hostsdirty_path);
244
				if (file_exists($d_staticmapsdirty_path))
245
					unlink($d_staticmapsdirty_path);
246
			}					
247
		} else {
248
			$retvaldhcp = services_dhcpd_configure();	
249
			if ($retvaldhcp == 0) {
250
				if (file_exists($d_staticmapsdirty_path))
251
					unlink($d_staticmapsdirty_path);
252
			}
253
		}	
254
		config_unlock();
255
		if($retvaldhcp == 1 || $retvaldns == 1)
256
			$retval = 1;
257
		$savemsg = get_std_save_message($retval);
258
	}
259
}
260

    
261
if ($_GET['act'] == "del") {
262
	if ($a_maps[$_GET['id']]) {
263
		unset($a_maps[$_GET['id']]);
264
		write_config();
265
		if(isset($config['dhcpd'][$if]['enable'])) {
266
			touch($d_staticmapsdirty_path);
267
			if (isset($config['dnsmasq']['regdhcpstatic']))
268
				touch($d_hostsdirty_path);
269
		}
270
		header("Location: services_dhcp.php?if={$if}");
271
		exit;
272
	}
273
}
274

    
275
$pgtitle = "Services: DHCP server";
276
include("head.inc");
277

    
278
?>
279

    
280
<script type="text/javascript" language="JavaScript">
281

    
282
function enable_change(enable_over) {
283
	var endis;
284
	endis = !(document.iform.enable.checked || enable_over);
285
	document.iform.range_from.disabled = endis;
286
	document.iform.range_to.disabled = endis;
287
	document.iform.wins1.disabled = endis;
288
	document.iform.wins2.disabled = endis;
289
	document.iform.dns1.disabled = endis;
290
	document.iform.dns2.disabled = endis;
291
	document.iform.deftime.disabled = endis;
292
	document.iform.maxtime.disabled = endis;
293
	document.iform.gateway.disabled = endis;
294
	document.iform.failover_peerip.disabled = endis;
295
	document.iform.staticarp.disabled = endis;
296
	document.iform.ddnsdomain.disabled = endis;
297
	document.iform.ddnsupdate.disabled = endis;
298
	document.iform.ntp1.disabled = endis;
299
	document.iform.ntp2.disabled = endis;
300
	document.iform.netboot.disabled = endis;
301
	document.iform.nextserver.disabled = endis;
302
	document.iform.filename.disabled = endis;
303
	document.iform.denyunknown.disabled = endis;
304
}
305

    
306
function show_ddns_config() {
307
	document.getElementById("showddnsbox").innerHTML='';
308
	aodiv = document.getElementById('showddns');
309
	aodiv.style.display = "block";
310
}
311

    
312
function show_ntp_config() {
313
	document.getElementById("showntpbox").innerHTML='';
314
	aodiv = document.getElementById('showntp');
315
	aodiv.style.display = "block";
316
}
317

    
318
function show_netboot_config() {
319
	document.getElementById("shownetbootbox").innerHTML='';
320
	aodiv = document.getElementById('shownetboot');
321
	aodiv.style.display = "block";
322
}
323

    
324
</script>
325

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