Project

General

Profile

Download (34.5 KB) Statistics
| Branch: | Tag: | Revision:
1 e9f147c8 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_dhcp.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 e9f147c8 Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 e9f147c8 Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 e9f147c8 Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 e9f147c8 Scott Ullrich
16 5b237745 Scott Ullrich
	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 e9f147c8 Scott Ullrich
20 5b237745 Scott Ullrich
	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 1d333258 Scott Ullrich
/*
32
	pfSense_BUILDER_BINARIES:	/bin/rm
33
	pfSense_MODULE:	interfaces
34
*/
35 5b237745 Scott Ullrich
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-services-dhcpserver
38
##|*NAME=Services: DHCP server page
39
##|*DESCR=Allow access to the 'Services: DHCP server' page.
40
##|*MATCH=services_dhcp.php*
41
##|-PRIV
42
43 b7597d4e Bill Marquette
require("guiconfig.inc");
44 5b237745 Scott Ullrich
45 2ee0410f Scott Ullrich
if(!$g['services_dhcp_server_enable']) {
46
	Header("Location: /");
47
	exit;
48
}
49
50 de792e62 jim-p
/*  Fix failover DHCP problem
51 d5f5cf26 Scott Ullrich
 *  http://article.gmane.org/gmane.comp.security.firewalls.pfsense.support/18749
52
 */
53
ini_set("memory_limit","64M");
54
55 c2ffc6c1 jim-p
/* This function will remove entries from dhcpd.leases that would otherwise
56
 * overlap with static DHCP reservations. If we don't clean these out,
57
 * then DHCP will print a warning in the logs about a duplicate lease
58
 */
59
function dhcp_clean_leases() {
60
	global $g, $config;
61
	$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
62 69ec9ecf jim-p
	if (!file_exists($leasesfile))
63
		return;
64 c2ffc6c1 jim-p
	/* Build list of static MACs */
65
	$staticmacs = array();
66
	foreach($config['interfaces'] as $ifname => $ifarr)
67
		if (is_array($config['dhcpd'][$ifname]['staticmap']))
68
			foreach($config['dhcpd'][$ifname]['staticmap'] as $static)
69
				$staticmacs[] = $static['mac'];
70
	/* Read existing leases */
71
	$leases_contents = explode("\n", file_get_contents($leasesfile));
72
	$newleases_contents = array();
73
	$i=0;
74
	while ($i < count($leases_contents)) {
75
		/* Find a lease definition */
76
		if (substr($leases_contents[$i], 0, 6) == "lease ") {
77
			$templease = array();
78
			$thismac = "";
79
			/* Read to the end of the lease declaration */
80
			do {
81
				if (substr($leases_contents[$i], 0, 20) == "  hardware ethernet ")
82
					$thismac = substr($leases_contents[$i], 20, 17);
83
				$templease[] = $leases_contents[$i];
84
				$i++;
85
			} while ($leases_contents[$i-1] != "}");
86
			/* Check for a matching MAC address and if not present, keep it. */
87
			if (! in_array($thismac, $staticmacs))
88
				$newleases_contents = array_merge($newleases_contents, $templease);
89
		} else {
90
			/* It's a line we want to keep, copy it over. */
91
			$newleases_contents[] = $leases_contents[$i];
92
			$i++;
93
		}
94
	}
95
	/* Write out the new leases file */
96
	$fd = fopen($leasesfile, 'w');
97
	fwrite($fd, implode("\n", $newleases_contents));
98
	fclose($fd);
99
}
100
101 5b237745 Scott Ullrich
$if = $_GET['if'];
102
if ($_POST['if'])
103
	$if = $_POST['if'];
104 e9f147c8 Scott Ullrich
105 11bc553c Scott Ullrich
/* if OLSRD is enabled, allow WAN to house DHCP. */
106 a3b466b5 Scott Ullrich
if($config['installedpackages']['olsrd']) {
107
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
108 bc15a1b9 Scott Ullrich
			if($olsrd['enable']) {
109 48ab0cd2 Scott Ullrich
				$is_olsr_enabled = true;
110 a3b466b5 Scott Ullrich
				break;
111
			}
112
	}
113 11bc553c Scott Ullrich
}
114
115 934240ef Ermal Luçi
if (!$_GET['if'])
116 55e52bc6 Chris Buechler
	$savemsg = "<b>The DHCP Server can only be enabled on interfaces configured with static IP addresses.<p> Only interfaces configured with a static IP will be shown.</p></b>";
117 5b237745 Scott Ullrich
118 934240ef Ermal Luçi
$iflist = get_configured_interface_with_descr();
119 5b237745 Scott Ullrich
120 1c451b06 Scott Ullrich
/* set the starting interface */
121 f19651d1 Ermal
if (!$if || !isset($iflist[$if])) {
122 01fdb2d3 Erik Fonnesbeck
	foreach ($iflist as $ifent => $ifname) {
123 de792e62 jim-p
		$oc = $config['interfaces'][$ifent];
124
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddr($oc['ipaddr']))) ||
125 01fdb2d3 Erik Fonnesbeck
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddr($oc['ipaddr']))))
126
			continue;
127
		$if = $ifent;
128
		break;
129
	}
130 f19651d1 Ermal
}
131 0a2c6a5b Scott Ullrich
132 89019922 Ermal Luçi
if (is_array($config['dhcpd'][$if])){
133
	if (is_array($config['dhcpd'][$if]['range'])) {
134
		$pconfig['range_from'] = $config['dhcpd'][$if]['range']['from'];
135
		$pconfig['range_to'] = $config['dhcpd'][$if]['range']['to'];
136 de792e62 jim-p
	}
137 89019922 Ermal Luçi
	$pconfig['deftime'] = $config['dhcpd'][$if]['defaultleasetime'];
138
	$pconfig['maxtime'] = $config['dhcpd'][$if]['maxleasetime'];
139
	$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
140
	$pconfig['domain'] = $config['dhcpd'][$if]['domain'];
141
	$pconfig['domainsearchlist'] = $config['dhcpd'][$if]['domainsearchlist'];
142
	list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
143
	list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
144
	$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
145
	$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
146
	$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
147
	$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
148
	$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
149
	list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
150
	$pconfig['tftp'] = $config['dhcpd'][$if]['tftp'];
151
	$pconfig['ldap'] = $config['dhcpd'][$if]['ldap'];
152
	$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
153
	$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
154
	$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
155
	$pconfig['rootpath'] = $config['dhcpd'][$if]['rootpath'];
156
	$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
157
	$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
158 518030b3 Scott Ullrich
	$pconfig['numberoptions'] = $config['dhcpd'][$if]['numberoptions'];
159 de792e62 jim-p
	if (!is_array($config['dhcpd'][$if]['staticmap']))
160
		$config['dhcpd'][$if]['staticmap'] = array();
161 89019922 Ermal Luçi
	$a_maps = &$config['dhcpd'][$if]['staticmap'];
162
}
163 31c59d0d Scott Ullrich
164 a55e9c70 Ermal Lu?i
$ifcfgip = get_interface_ip($if);
165
$ifcfgsn = get_interface_subnet($if);
166 5b237745 Scott Ullrich
167 3d7b7757 Chris Buechler
/*   set the enabled flag which will tell us if DHCP relay is enabled
168 de792e62 jim-p
 *   on any interface. We will use this to disable DHCP server since
169 3d7b7757 Chris Buechler
 *   the two are not compatible with each other.
170
 */
171
172
$dhcrelay_enabled = false;
173
$dhcrelaycfg = $config['dhcrelay'];
174
175
if(is_array($dhcrelaycfg)) {
176
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
177 0c87f8fa Ermal Lu?i
		if (isset($dhcrelayifconf['enable']) && isset($iflist[$dhcrelayif]) &&
178
			(!link_interface_to_bridge($dhcrelayif)))
179 3d7b7757 Chris Buechler
			$dhcrelay_enabled = true;
180
	}
181
}
182
183 0ea7462d Bill Marquette
function is_inrange($test, $start, $end) {
184 96033063 Erik Fonnesbeck
	if ( (ip2ulong($test) < ip2ulong($end)) && (ip2ulong($test) > ip2ulong($start)) )
185 0ea7462d Bill Marquette
		return true;
186
	else
187
		return false;
188
}
189 b7597d4e Bill Marquette
190 5b237745 Scott Ullrich
if ($_POST) {
191
192
	unset($input_errors);
193 b7597d4e Bill Marquette
194 5b237745 Scott Ullrich
	$pconfig = $_POST;
195
196 6d1af0e9 jim-p
	$numberoptions = array();
197
	for($x=0; $x<99; $x++) {
198
		if(isset($_POST["number{$x}"]) && ctype_digit($_POST["number{$x}"])) {
199
			$numbervalue = array();
200
			$numbervalue['number'] = htmlspecialchars($_POST["number{$x}"]);
201
			$numbervalue['value'] = htmlspecialchars($_POST["value{$x}"]);
202
			$numberoptions['item'][] = $numbervalue;
203
		}
204
	}
205
	// Reload the new pconfig variable that the forum uses.
206
	$pconfig['numberoptions'] = $numberoptions;
207
208 5b237745 Scott Ullrich
	/* input validation */
209
	if ($_POST['enable']) {
210
		$reqdfields = explode(" ", "range_from range_to");
211
		$reqdfieldsn = explode(",", "Range begin,Range end");
212 e9f147c8 Scott Ullrich
213 5b237745 Scott Ullrich
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
214 de792e62 jim-p
215
		if (($_POST['range_from'] && !is_ipaddr($_POST['range_from'])))
216 5b237745 Scott Ullrich
			$input_errors[] = "A valid range must be specified.";
217 de792e62 jim-p
		if (($_POST['range_to'] && !is_ipaddr($_POST['range_to'])))
218 5b237745 Scott Ullrich
			$input_errors[] = "A valid range must be specified.";
219 de792e62 jim-p
		if (($_POST['gateway'] && !is_ipaddr($_POST['gateway'])))
220 f9261419 Bill Marquette
			$input_errors[] = "A valid IP address must be specified for the gateway.";
221 de792e62 jim-p
		if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2'])))
222 4cab31d0 Scott Ullrich
			$input_errors[] = "A valid IP address must be specified for the primary/secondary WINS servers.";
223 de792e62 jim-p
		if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2'])))
224 4cab31d0 Scott Ullrich
			$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS servers.";
225 26e3ca70 sullrich
226 de792e62 jim-p
		if ($_POST['deftime'] && (!is_numeric($_POST['deftime']) || ($_POST['deftime'] < 60)))
227 5b237745 Scott Ullrich
			$input_errors[] = "The default lease time must be at least 60 seconds.";
228 de792e62 jim-p
		if ($_POST['maxtime'] && (!is_numeric($_POST['maxtime']) || ($_POST['maxtime'] < 60) || ($_POST['maxtime'] <= $_POST['deftime'])))
229 5b237745 Scott Ullrich
			$input_errors[] = "The maximum lease time must be at least 60 seconds and higher than the default lease time.";
230 de792e62 jim-p
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain'])))
231 4e9cd828 Seth Mos
			$input_errors[] = "A valid domain name must be specified for the dynamic DNS registration.";
232 de792e62 jim-p
		if (($_POST['ntp1'] && !is_ipaddr($_POST['ntp1'])) || ($_POST['ntp2'] && !is_ipaddr($_POST['ntp2'])))
233 ad171999 Seth Mos
			$input_errors[] = "A valid IP address must be specified for the primary/secondary NTP servers.";
234 26e3ca70 sullrich
		if (($_POST['domain'] && !is_domain($_POST['domain'])))
235 ee1b024e Martin Fuchs
			$input_errors[] = "A valid domain name must be specified for the DNS domain.";
236 e4b8da19 Chris Buechler
		if (($_POST['tftp'] && (!is_ipaddr($_POST['tftp']) && !is_domain($_POST['tftp']))))
237
			$input_errors[] = "A valid IP address or hostname must be specified for the TFTP server.";
238 de792e62 jim-p
		if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver'])))
239 4e9cd828 Seth Mos
			$input_errors[] = "A valid IP address must be specified for the network boot server.";
240 2c75b451 sullrich
241 26e3ca70 sullrich
		if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from'])
242
			$input_errors[] = "You cannot use the network address in the starting subnet range.";
243
		if(gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to'])
244
			$input_errors[] = "You cannot use the broadcast address in the ending subnet range.";
245 e9f147c8 Scott Ullrich
246 2c75b451 sullrich
		// Disallow a range that includes the virtualip
247 7dfa60fa Ermal Lu?i
		if (is_array($config['virtualip']['vip'])) {
248
			foreach($config['virtualip']['vip'] as $vip) {
249 de792e62 jim-p
				if($vip['interface'] == $if)
250
					if($vip['subnet'] && is_inrange($vip['subnet'], $_POST['range_from'], $_POST['range_to']))
251 f9150249 Chris Buechler
						$input_errors[] = "The subnet range cannot overlap with virtual IP address {$vip['subnet']}.";
252 7dfa60fa Ermal Lu?i
			}
253 2c75b451 sullrich
		}
254
255 5b237745 Scott Ullrich
		if (!$input_errors) {
256
			/* make sure the range lies within the current subnet */
257 96033063 Erik Fonnesbeck
			$subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
258
			$subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
259 e9f147c8 Scott Ullrich
260 96033063 Erik Fonnesbeck
			if ((ip2ulong($_POST['range_from']) < $subnet_start) || (ip2ulong($_POST['range_from']) > $subnet_end) ||
261
			    (ip2ulong($_POST['range_to']) < $subnet_start) || (ip2ulong($_POST['range_to']) > $subnet_end)) {
262 e9f147c8 Scott Ullrich
				$input_errors[] = "The specified range lies outside of the current subnet.";
263 5b237745 Scott Ullrich
			}
264 e9f147c8 Scott Ullrich
265 96033063 Erik Fonnesbeck
			if (ip2ulong($_POST['range_from']) > ip2ulong($_POST['range_to']))
266 5b237745 Scott Ullrich
				$input_errors[] = "The range is invalid (first element higher than second element).";
267 e9f147c8 Scott Ullrich
268 5b237745 Scott Ullrich
			/* make sure that the DHCP Relay isn't enabled on this interface */
269
			if (isset($config['dhcrelay'][$if]['enable']))
270
				$input_errors[] = "You must disable the DHCP relay on the {$iflist[$if]} interface before enabling the DHCP server.";
271
		}
272
	}
273
274
	if (!$input_errors) {
275 89019922 Ermal Luçi
		if (!is_array($config['dhcpd'][$if]))
276
			$config['dhcpd'][$if] = array();
277
		if (!is_array($config['dhcpd'][$if]['range']))
278
			$config['dhcpd'][$if]['range'] = array();
279
280 5b237745 Scott Ullrich
		$config['dhcpd'][$if]['range']['from'] = $_POST['range_from'];
281
		$config['dhcpd'][$if]['range']['to'] = $_POST['range_to'];
282
		$config['dhcpd'][$if]['defaultleasetime'] = $_POST['deftime'];
283
		$config['dhcpd'][$if]['maxleasetime'] = $_POST['maxtime'];
284 48ab0cd2 Scott Ullrich
		$config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
285 d378c59b Scott Ullrich
		$previous = $config['dhcpd'][$if]['failover_peerip'];
286 de792e62 jim-p
		if($previous <> $_POST['failover_peerip'])
287 1d333258 Scott Ullrich
			mwexec("/bin/rm -rf /var/dhcpd/var/db/*");
288
289 ea166a33 Scott Ullrich
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
290 e9f147c8 Scott Ullrich
291 5b237745 Scott Ullrich
		unset($config['dhcpd'][$if]['winsserver']);
292
		if ($_POST['wins1'])
293
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins1'];
294
		if ($_POST['wins2'])
295
			$config['dhcpd'][$if]['winsserver'][] = $_POST['wins2'];
296 4cab31d0 Scott Ullrich
297 94a9cf1a Scott Ullrich
		unset($config['dhcpd'][$if]['dnsserver']);
298 e9f147c8 Scott Ullrich
		if ($_POST['dns1'])
299 06d754d4 Scott Ullrich
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
300 e9f147c8 Scott Ullrich
		if ($_POST['dns2'])
301 06d754d4 Scott Ullrich
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
302 e9f147c8 Scott Ullrich
303 f9261419 Bill Marquette
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
304 1ebf937f Martin Fuchs
		$config['dhcpd'][$if]['domain'] = $_POST['domain'];
305 9be23653 Martin Fuchs
		$config['dhcpd'][$if]['domainsearchlist'] = $_POST['domainsearchlist'];
306 6a01ea44 Bill Marquette
		$config['dhcpd'][$if]['denyunknown'] = ($_POST['denyunknown']) ? true : false;
307
		$config['dhcpd'][$if]['enable'] = ($_POST['enable']) ? true : false;
308
		$config['dhcpd'][$if]['staticarp'] = ($_POST['staticarp']) ? true : false;
309 4e9cd828 Seth Mos
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
310
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
311 ad171999 Seth Mos
312
		unset($config['dhcpd'][$if]['ntpserver']);
313
		if ($_POST['ntp1'])
314
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp1'];
315
		if ($_POST['ntp2'])
316
			$config['dhcpd'][$if]['ntpserver'][] = $_POST['ntp2'];
317
318 6c23757b Martin Fuchs
		$config['dhcpd'][$if]['tftp'] = $_POST['tftp'];
319
		$config['dhcpd'][$if]['ldap'] = $_POST['ldap'];
320 4e9cd828 Seth Mos
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
321
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
322
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
323 ee1b024e Martin Fuchs
		$config['dhcpd'][$if]['rootpath'] = $_POST['rootpath'];
324 9c748b70 Scott Ullrich
325 d72b4114 Scott Ullrich
		// Handle the custom options rowhelper
326 11de5c3d Chris Buechler
		if(isset($config['dhcpd'][$if]['numberoptions']['item']))
327
			unset($config['dhcpd'][$if]['numberoptions']['item']);
328 6d1af0e9 jim-p
329
		$config['dhcpd'][$if]['numberoptions'] = $numberoptions;
330 518030b3 Scott Ullrich
331 5b237745 Scott Ullrich
		write_config();
332 80933129 Bill Marquette
333
		/* static arp configuration */
334 c5a0fd3c Scott Ullrich
		interfaces_staticarp_configure($if);
335 e9f147c8 Scott Ullrich
336 5b237745 Scott Ullrich
		$retval = 0;
337 6a01ea44 Bill Marquette
		$retvaldhcp = 0;
338
		$retvaldns = 0;
339 c2ffc6c1 jim-p
		/* Stop DHCP so we can cleanup leases */
340
		killbyname("dhcpd");
341
		dhcp_clean_leases();
342 6a01ea44 Bill Marquette
		/* dnsmasq_configure calls dhcpd_configure */
343
		/* no need to restart dhcpd twice */
344
		if (isset($config['dnsmasq']['regdhcpstatic']))	{
345
			$retvaldns = services_dnsmasq_configure();
346
			if ($retvaldns == 0) {
347 a368a026 Ermal Lu?i
				clear_subsystem_dirty('hosts');
348
				clear_subsystem_dirty('staticmaps');
349 de792e62 jim-p
			}
350 6a01ea44 Bill Marquette
		} else {
351 de792e62 jim-p
			$retvaldhcp = services_dhcpd_configure();
352 a368a026 Ermal Lu?i
			if ($retvaldhcp == 0)
353
				clear_subsystem_dirty('staticmaps');
354 de792e62 jim-p
		}
355 6a01ea44 Bill Marquette
		if($retvaldhcp == 1 || $retvaldns == 1)
356
			$retval = 1;
357 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
358
	}
359
}
360
361
if ($_GET['act'] == "del") {
362
	if ($a_maps[$_GET['id']]) {
363
		unset($a_maps[$_GET['id']]);
364
		write_config();
365 6a01ea44 Bill Marquette
		if(isset($config['dhcpd'][$if]['enable'])) {
366 a368a026 Ermal Lu?i
			mark_subsystem_dirty('staticmaps');
367 6a01ea44 Bill Marquette
			if (isset($config['dnsmasq']['regdhcpstatic']))
368 a368a026 Ermal Lu?i
				mark_subsystem_dirty('hosts');
369 6a01ea44 Bill Marquette
		}
370 5b237745 Scott Ullrich
		header("Location: services_dhcp.php?if={$if}");
371
		exit;
372
	}
373
}
374 4df96eff Scott Ullrich
375 d88c6a9f Scott Ullrich
$pgtitle = array("Services","DHCP server");
376 b9546722 Chris Buechler
$statusurl = "status_dhcp_leases.php";
377 5224b8e7 jim-p
$logurl = "diag_logs_dhcp.php";
378
379 4df96eff Scott Ullrich
include("head.inc");
380
381 5b237745 Scott Ullrich
?>
382 4df96eff Scott Ullrich
383 518030b3 Scott Ullrich
<script type="text/javascript" src="/javascript/row_helper.js">
384
</script>
385 4e9cd828 Seth Mos
386 518030b3 Scott Ullrich
<script type="text/javascript">
387
	rowname[0] = "number";
388
	rowtype[0] = "textbox";
389 4e10cf0a Scott Ullrich
	rowsize[0] = "10";
390 518030b3 Scott Ullrich
	rowname[1] = "value";
391
	rowtype[1] = "textbox";
392 4e10cf0a Scott Ullrich
	rowsize[1] = "55";
393 518030b3 Scott Ullrich
</script>
394 4e9cd828 Seth Mos
395 518030b3 Scott Ullrich
<script type="text/javascript" language="JavaScript">
396
	function enable_change(enable_over) {
397
		var endis;
398
		endis = !(document.iform.enable.checked || enable_over);
399
		document.iform.range_from.disabled = endis;
400
		document.iform.range_to.disabled = endis;
401
		document.iform.wins1.disabled = endis;
402
		document.iform.wins2.disabled = endis;
403
		document.iform.dns1.disabled = endis;
404
		document.iform.dns2.disabled = endis;
405
		document.iform.deftime.disabled = endis;
406
		document.iform.maxtime.disabled = endis;
407
		document.iform.gateway.disabled = endis;
408
		document.iform.failover_peerip.disabled = endis;
409
		document.iform.domain.disabled = endis;
410
		document.iform.domainsearchlist.disabled = endis;
411
		document.iform.staticarp.disabled = endis;
412
		document.iform.ddnsdomain.disabled = endis;
413
		document.iform.ddnsupdate.disabled = endis;
414
		document.iform.ntp1.disabled = endis;
415
		document.iform.ntp2.disabled = endis;
416
		document.iform.tftp.disabled = endis;
417
		document.iform.ldap.disabled = endis;
418
		document.iform.netboot.disabled = endis;
419
		document.iform.nextserver.disabled = endis;
420
		document.iform.filename.disabled = endis;
421
		document.iform.rootpath.disabled = endis;
422
		document.iform.denyunknown.disabled = endis;
423
	}
424 4e9cd828 Seth Mos
425 b1d132f5 Scott Ullrich
	function show_shownumbervalue() {
426
		document.getElementById("shownumbervaluebox").innerHTML='';
427
		aodiv = document.getElementById('shownumbervalue');
428
		aodiv.style.display = "block";
429
	}
430
431 518030b3 Scott Ullrich
	function show_ddns_config() {
432
		document.getElementById("showddnsbox").innerHTML='';
433
		aodiv = document.getElementById('showddns');
434
		aodiv.style.display = "block";
435
	}
436 ad171999 Seth Mos
437 518030b3 Scott Ullrich
	function show_ntp_config() {
438
		document.getElementById("showntpbox").innerHTML='';
439
		aodiv = document.getElementById('showntp');
440
		aodiv.style.display = "block";
441
	}
442 6c23757b Martin Fuchs
443 518030b3 Scott Ullrich
	function show_tftp_config() {
444
		document.getElementById("showtftpbox").innerHTML='';
445
		aodiv = document.getElementById('showtftp');
446
		aodiv.style.display = "block";
447
	}
448 6c23757b Martin Fuchs
449 518030b3 Scott Ullrich
	function show_ldap_config() {
450
		document.getElementById("showldapbox").innerHTML='';
451
		aodiv = document.getElementById('showldap');
452
		aodiv.style.display = "block";
453
	}
454 4e9cd828 Seth Mos
455 518030b3 Scott Ullrich
	function show_netboot_config() {
456
		document.getElementById("shownetbootbox").innerHTML='';
457
		aodiv = document.getElementById('shownetboot');
458
		aodiv.style.display = "block";
459
	}
460 5b237745 Scott Ullrich
</script>
461
462
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
463 b7597d4e Bill Marquette
<?php include("fbegin.inc"); ?>
464 5b237745 Scott Ullrich
<form action="services_dhcp.php" method="post" name="iform" id="iform">
465
<?php if ($input_errors) print_input_errors($input_errors); ?>
466
<?php if ($savemsg) print_info_box($savemsg); ?>
467 de792e62 jim-p
<?php
468 3d7b7757 Chris Buechler
	if ($dhcrelay_enabled) {
469 de792e62 jim-p
		echo "DHCP Relay is currently enabled. Cannot enable the DHCP Server service while the DHCP Relay is enabled on any interface.";
470
		include("fend.inc");
471 3d7b7757 Chris Buechler
		echo "</body>";
472
		echo "</html>";
473
		exit;
474
	}
475
?>
476 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('staticmaps')): ?><p>
477 5b237745 Scott Ullrich
<?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>
478
<?php endif; ?>
479
<table width="100%" border="0" cellpadding="0" cellspacing="0">
480 de792e62 jim-p
<tr><td>
481
<?php
482 f0cdf141 Scott Ullrich
	/* active tabs */
483
	$tab_array = array();
484
	$tabscounter = 0;
485
	$i = 0;
486
	foreach ($iflist as $ifent => $ifname) {
487 de792e62 jim-p
		$oc = $config['interfaces'][$ifent];
488
		if ((is_array($config['dhcpd'][$ifent]) && !isset($config['dhcpd'][$ifent]['enable']) && (!is_ipaddr($oc['ipaddr']))) ||
489 a0d1dc56 Ermal Lu?i
			(!is_array($config['dhcpd'][$ifent]) && (!is_ipaddr($oc['ipaddr']))))
490 934240ef Ermal Luçi
			continue;
491 f0cdf141 Scott Ullrich
		if ($ifent == $if)
492
			$active = true;
493
		else
494
			$active = false;
495
		$tab_array[] = array($ifname, $active, "services_dhcp.php?if={$ifent}");
496 934240ef Ermal Luçi
		$tabscounter++;
497
	}
498
	if ($tabscounter == 0) {
499
		echo "</td></tr></table></form>";
500
		include("fend.inc");
501
		echo "</body>";
502
		echo "</html>";
503
		exit;
504 f0cdf141 Scott Ullrich
	}
505
	display_top_tabs($tab_array);
506 de792e62 jim-p
?>
507
</td></tr>
508
<tr>
509
<td>
510 d732f186 Bill Marquette
	<div id="mainarea">
511 de792e62 jim-p
		<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
512
			<tr>
513
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
514
			<td width="78%" class="vtable">
515
				<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
516
			<strong>Enable DHCP server on
517
			<?=htmlspecialchars($iflist[$if]);?>
518
			interface</strong></td>
519
			</tr>
520
			<tr>
521
			<td width="22%" valign="top" class="vtable">&nbsp;</td>
522
			<td width="78%" class="vtable">
523
				<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
524
				<strong>Deny unknown clients</strong><br>
525
				If this is checked, only the clients defined below will get DHCP leases from this server. </td>
526
			</tr>
527
			<tr>
528
			<td width="22%" valign="top" class="vncellreq">Subnet</td>
529
			<td width="78%" class="vtable">
530
				<?=gen_subnet($ifcfgip, $ifcfgsn);?>
531
			</td>
532
			</tr>
533
			<tr>
534
			<td width="22%" valign="top" class="vncellreq">Subnet mask</td>
535
			<td width="78%" class="vtable">
536
				<?=gen_subnet_mask($ifcfgsn);?>
537
			</td>
538
			</tr>
539
			<tr>
540
			<td width="22%" valign="top" class="vncellreq">Available range</td>
541
			<td width="78%" class="vtable">
542
			<?php
543
				$range_from = ip2long(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
544
				$range_from++;
545
				echo long2ip32($range_from);
546
			?>
547
			-
548
			<?php
549
				$range_to = ip2long(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn))));
550
				$range_to--;
551
				echo long2ip32($range_to);
552
			?>
553
			</td>
554
			</tr>
555
			<?php if($is_olsr_enabled): ?>
556
			<tr>
557
			<td width="22%" valign="top" class="vncellreq">Subnet Mask</td>
558
			<td width="78%" class="vtable">
559
				<select name="netmask" class="formselect" id="netmask">
560
				<?php
561
				for ($i = 32; $i > 0; $i--) {
562
					if($i <> 31) {
563
						echo "<option value=\"{$i}\" ";
564
						if ($i == $pconfig['netmask']) echo "selected";
565
						echo ">" . $i . "</option>";
566
					}
567
				}
568
				?>
569
				</select>
570
			</td>
571
			</tr>
572
			<?php endif; ?>
573
			<tr>
574
			<td width="22%" valign="top" class="vncellreq">Range</td>
575
			<td width="78%" class="vtable">
576
				<input name="range_from" type="text" class="formfld unknown" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>">
577
				&nbsp;to&nbsp; <input name="range_to" type="text" class="formfld unknown" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>">
578
			</td>
579
			</tr>
580
			<tr>
581
			<td width="22%" valign="top" class="vncell">WINS servers</td>
582
			<td width="78%" class="vtable">
583
				<input name="wins1" type="text" class="formfld unknown" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>"><br>
584
				<input name="wins2" type="text" class="formfld unknown" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>">
585
			</td>
586
			</tr>
587
			<tr>
588
			<td width="22%" valign="top" class="vncell">DNS servers</td>
589
			<td width="78%" class="vtable">
590
				<input name="dns1" type="text" class="formfld unknown" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
591
				<input name="dns2" type="text" class="formfld unknown" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
592
				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.
593
			</td>
594
			</tr>
595
			<tr>
596
			<td width="22%" valign="top" class="vncell">Gateway</td>
597
			<td width="78%" class="vtable">
598
				<input name="gateway" type="text" class="formfld host" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
599
			 	 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.
600
			</td>
601
			</tr>
602
			<tr>
603
			<td width="22%" valign="top" class="vncell">Domain name</td>
604
			<td width="78%" class="vtable">
605
				<input name="domain" type="text" class="formfld unknown" id="domain" size="20" value="<?=htmlspecialchars($pconfig['domain']);?>"><br>
606
				 The default is to use the domain name of this system as the default domain name provided by DHCP. You may specify an alternate domain name here.
607
			 </td>
608
			</tr>
609
			<tr>
610
			<td width="22%" valign="top" class="vncell">Domain search list</td>
611
			<td width="78%" class="vtable">
612
				<input name="domainsearchlist" type="text" class="formfld unknown" id="domainsearchlist" size="20" value="<?=htmlspecialchars($pconfig['domainsearchlist']);?>"><br>
613
				The DHCP server can optionally provide a domain search list.
614
			</td>
615
			</tr>
616
			<tr>
617
			<td width="22%" valign="top" class="vncell">Default lease time</td>
618
			<td width="78%" class="vtable">
619
				<input name="deftime" type="text" class="formfld unknown" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
620
				seconds<br>
621
				This is used for clients that do not ask for a specific
622
				expiration time.<br>
623
				The default is 7200 seconds.
624
			</td>
625
			</tr>
626
			<tr>
627
			<td width="22%" valign="top" class="vncell">Maximum lease time</td>
628
			<td width="78%" class="vtable">
629
				<input name="maxtime" type="text" class="formfld unknown" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
630
				seconds<br>
631
				This is the maximum lease time for clients that ask
632
				for a specific expiration time.<br>
633
				The default is 86400 seconds.
634
			</td>
635
			</tr>
636
			<tr>
637
			<td width="22%" valign="top" class="vncell">Failover peer IP:</td>
638
			<td width="78%" class="vtable">
639 b5c78501 Seth Mos
				<input name="failover_peerip" type="text" class="formfld host" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
640 3a4fb57e Chris Buechler
				Leave blank to disable.  Enter the interface IP address of the other machine.  Machines must be using CARP.
641 ea166a33 Scott Ullrich
			</td>
642 518030b3 Scott Ullrich
			</tr>
643
			<tr>
644 de792e62 jim-p
			<td width="22%" valign="top" class="vncell">Static ARP</td>
645
			<td width="78%" class="vtable">
646
				<table>
647
					<tr>
648
					<td>
649
						<input valign="middle" type="checkbox" value="yes" name="staticarp" id="staticarp" <?php if($pconfig['staticarp']) echo " checked"; ?>>&nbsp;
650
					</td>
651
					<td><b>Enable Static ARP entries</b></td>
652
					</tr>
653
					<tr>
654
					<td>&nbsp;</td>
655
					<td>
656
						<span class="red"><strong>Note:</strong></span> Only the machines listed below will be able to communicate with the firewall on this NIC.
657
					</td>
658
					</tr>
659
				</table>
660
			</td>
661 518030b3 Scott Ullrich
			</tr>
662
			<tr>
663 de792e62 jim-p
			<td width="22%" valign="top" class="vncell">Dynamic DNS</td>
664
			<td width="78%" class="vtable">
665
				<div id="showddnsbox">
666
					<input type="button" onClick="show_ddns_config()" value="Advanced"></input> - Show Dynamic DNS</a>
667
				</div>
668
				<div id="showddns" style="display:none">
669
					<input valign="middle" type="checkbox" value="yes" name="ddnsupdate" id="ddnsupdate" <?php if($pconfig['ddnsupdate']) echo " checked"; ?>>&nbsp;
670
					<b>Enable registration of DHCP client names in DNS.</b><br />
671
					<p>
672
					<input name="ddnsdomain" type="text" class="formfld unknown" id="ddnsdomain" size="20" value="<?=htmlspecialchars($pconfig['ddnsdomain']);?>"><br />
673
					Note: Leave blank to disable dynamic DNS registration.<br />
674
					Enter the dynamic DNS domain which will be used to register client names in the DNS server.
675
				</div>
676
			</td>
677
			</tr>
678 518030b3 Scott Ullrich
			<tr>
679 de792e62 jim-p
			<td width="22%" valign="top" class="vncell">NTP servers</td>
680
			<td width="78%" class="vtable">
681 ad171999 Seth Mos
				<div id="showntpbox">
682
					<input type="button" onClick="show_ntp_config()" value="Advanced"></input> - Show NTP configuration</a>
683
				</div>
684
				<div id="showntp" style="display:none">
685 b5c78501 Seth Mos
					<input name="ntp1" type="text" class="formfld unknown" id="ntp1" size="20" value="<?=htmlspecialchars($pconfig['ntp1']);?>"><br>
686
					<input name="ntp2" type="text" class="formfld unknown" id="ntp2" size="20" value="<?=htmlspecialchars($pconfig['ntp2']);?>">
687 ad171999 Seth Mos
				</div>
688
			</td>
689 518030b3 Scott Ullrich
			</tr>
690
			<tr>
691 de792e62 jim-p
			<td width="22%" valign="top" class="vncell">TFTP server</td>
692
			<td width="78%" class="vtable">
693
			<div id="showtftpbox">
694
				<input type="button" onClick="show_tftp_config()" value="Advanced"></input> - Show TFTP configuration</a>
695
			</div>
696
			<div id="showtftp" style="display:none">
697
				<input name="tftp" type="text" class="formfld unknown" id="tftp" size="50" value="<?=htmlspecialchars($pconfig['tftp']);?>"><br>
698
				Leave blank to disable.  Enter a full hostname or IP for the TFTP server.
699
			</div>
700 6c23757b Martin Fuchs
			</td>
701 518030b3 Scott Ullrich
			</tr>
702
			<tr>
703 de792e62 jim-p
			<td width="22%" valign="top" class="vncell">LDAP URI</td>
704
			<td width="78%" class="vtable">
705
				<div id="showldapbox">
706
					<input type="button" onClick="show_ldap_config()" value="Advanced"></input> - Show LDAP configuration</a>
707
				</div>
708
				<div id="showldap" style="display:none">
709
					<input name="ldap" type="text" class="formfld unknown" id="ldap" size="80" value="<?=htmlspecialchars($pconfig['ldap']);?>"><br>
710
					Leave blank to disable.  Enter a full URI for the LDAP server in the form ldap://ldap.example.com/dc=example,dc=com
711
				</div>
712
			</td>
713 518030b3 Scott Ullrich
			</tr>
714
			<tr>
715 de792e62 jim-p
			<td width="22%" valign="top" class="vncell">Enable network booting</td>
716
			<td width="78%" class="vtable">
717
				<div id="shownetbootbox">
718
					<input type="button" onClick="show_netboot_config()" value="Advanced"></input> - Show Network booting</a>
719
				</div>
720
				<div id="shownetboot" style="display:none">
721
					<input valign="middle" type="checkbox" value="yes" name="netboot" id="netboot" <?php if($pconfig['netboot']) echo " checked"; ?>>&nbsp;
722
					<b>Enables network booting.</b>
723
					<p>
724
					Enter the IP of the <b>next-server</b>
725
					<input name="nextserver" type="text" class="formfld unknown" id="nextserver" size="20" value="<?=htmlspecialchars($pconfig['nextserver']);?>">
726
					and the filename
727
					<input name="filename" type="text" class="formfld unknown" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>"><br>
728
					Note: You need both a filename and a boot server configured for this to work!
729
					<p>
730
					Enter the <b>root-path</b>-string
731
					<input name="rootpath" type="text" class="formfld unknown" id="rootpath" size="90" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br>
732
					Note: string-format: iscsi:(servername):(protocol):(port):(LUN):targetname
733
				</div>
734 4e9cd828 Seth Mos
			</td>
735 518030b3 Scott Ullrich
			</tr>
736
			<tr>
737 de792e62 jim-p
			<td width="22%" valign="top" class="vncell">Additional BOOTP/DHCP Options</td>
738
			<td width="78%" class="vtable">
739
				<div id="shownumbervaluebox">
740
					<input type="button" onClick="show_shownumbervalue()" value="Advanced"></input> - Show Additional BOOTP/DHCP Options</a>
741
				</div>
742
				<div id="shownumbervalue" style="display:none">
743
				<table id="maintable">
744
				<tbody>
745
				<tr>
746
				<td colspan="3">
747
					<div style="padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;" id="itemhelp">
748
					Enter the DHCP option number and the value for each item you would like to include in the DHCP lease information.  For a list of available options please visit this <a href="http://www.iana.org/assignments/bootp-dhcp-parameters/" target="_new">URL</a>.
749 b1d132f5 Scott Ullrich
					</div>
750 de792e62 jim-p
				</td>
751
				</tr>
752
				<tr>
753
				<td><div id="onecolumn">Number</div></td>
754
				<td><div id="twocolumn">Value</div></td>
755
				</tr>
756 518030b3 Scott Ullrich
				<?php $counter = 0; ?>
757 de792e62 jim-p
				<?php
758 518030b3 Scott Ullrich
					if($pconfig['numberoptions'])
759 de792e62 jim-p
						foreach($pconfig['numberoptions']['item'] as $item):
760 518030b3 Scott Ullrich
				?>
761
					<?php
762
						$number = $item['number'];
763
						$value = $item['value'];
764
					?>
765 de792e62 jim-p
				<tr>
766
				<td>
767
					<input autocomplete="off" name="number<?php echo $counter; ?>" type="text" class="formfld" id="number<?php echo $counter; ?>" size="10" value="<?=htmlspecialchars($number);?>" />
768
				</td>
769
				<td>
770
					<input autocomplete="off" name="value<?php echo $counter; ?>" type="text" class="formfld" id="value<?php echo $counter; ?>" size="55" value="<?=htmlspecialchars($value);?>" />
771
				</td>
772
				<td>
773
					<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete" />
774
				</td>
775
				</tr>
776 518030b3 Scott Ullrich
				<?php $counter++; ?>
777
				<?php endforeach; ?>
778 de792e62 jim-p
				</tbody>
779
				<tfoot>
780
				</tfoot>
781 518030b3 Scott Ullrich
				</table>
782
				<a onclick="javascript:addRowTo('maintable', 'formfldalias'); return false;" href="#">
783
					<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
784
				</a>
785
				<script type="text/javascript">
786
					field_counter_js = 2;
787
					rows = 1;
788
					totalrows = <?php echo $counter; ?>;
789
					loaded = <?php echo $counter; ?>;
790
				</script>
791 b1d132f5 Scott Ullrich
				</div>
792 518030b3 Scott Ullrich
793
				</td>
794
			</tr>
795
			<tr>
796 de792e62 jim-p
			<td width="22%" valign="top">&nbsp;</td>
797
			<td width="78%">
798
				<input name="if" type="hidden" value="<?=$if;?>">
799
				<input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
800
			</td>
801
			</tr>
802
			<tr>
803
			<td width="22%" valign="top">&nbsp;</td>
804
			<td width="78%"> <p><span class="vexpl"><span class="red"><strong>Note:<br>
805
				</strong></span>The DNS servers entered in <a href="system.php">System:
806
				General setup</a> (or the <a href="services_dnsmasq.php">DNS
807
				forwarder</a>, if enabled) </span><span class="vexpl">will
808
				be assigned to clients by the DHCP server.<br>
809
				<br>
810 b9546722 Chris Buechler
				The DHCP lease table can be viewed on the <a href="status_dhcp_leases.php">Status:
811 de792e62 jim-p
				DHCP leases</a> page.<br>
812
				</span></p>
813
			</td>
814 518030b3 Scott Ullrich
			</tr>
815
		</table>
816 7128ed17 Scott Ullrich
		<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
817 518030b3 Scott Ullrich
		<tr>
818
			<td width="25%" class="listhdrr">MAC address</td>
819
			<td width="15%" class="listhdrr">IP address</td>
820
			<td width="20%" class="listhdrr">Hostname</td>
821
			<td width="30%" class="listhdr">Description</td>
822
			<td width="10%" class="list">
823
			<table border="0" cellspacing="0" cellpadding="1">
824 de792e62 jim-p
			<tr>
825 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
826 518030b3 Scott Ullrich
			<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>
827
			</tr>
828
			</table>
829
			</td>
830 2af4c579 Scott Ullrich
		</tr>
831 de792e62 jim-p
			<?php if(is_array($a_maps)): ?>
832
			<?php $i = 0; foreach ($a_maps as $mapent): ?>
833
			<?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
834
		<tr>
835
		<td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
836
			<?=htmlspecialchars($mapent['mac']);?>
837
		</td>
838
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
839
			<?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
840
		</td>
841
		<td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
842
			<?=htmlspecialchars($mapent['hostname']);?>&nbsp;
843
		</td>
844
		<td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
845
			<?=htmlspecialchars($mapent['descr']);?>&nbsp;
846
		</td>
847
		<td valign="middle" nowrap class="list">
848
			<table border="0" cellspacing="0" cellpadding="1">
849
			<tr>
850
			<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>
851
			<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>
852
			</tr>
853
			</table>
854
		</td>
855
		</tr>
856 6f5b2c3e Scott Ullrich
		<?php endif; ?>
857 75a70796 Bill Marquette
		<?php $i++; endforeach; ?>
858 6f5b2c3e Scott Ullrich
		<?php endif; ?>
859 de792e62 jim-p
		<tr>
860
		<td class="list" colspan="4"></td>
861
		<td class="list">
862
			<table border="0" cellspacing="0" cellpadding="1">
863
			<tr>
864 d415d821 Seth Mos
			<td valign="middle" width="17"></td>
865 de792e62 jim-p
			<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>
866
			</tr>
867
			</table>
868
		</td>
869
		</tr>
870
		</table>
871 d732f186 Bill Marquette
	</div>
872 de792e62 jim-p
</td>
873
</tr>
874 5b237745 Scott Ullrich
</table>
875
</form>
876
<script language="JavaScript">
877
<!--
878
enable_change(false);
879
//-->
880
</script>
881 b7597d4e Bill Marquette
<?php include("fend.inc"); ?>
882 5b237745 Scott Ullrich
</body>
883
</html>