Project

General

Profile

Download (27.3 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
32 b7597d4e Bill Marquette
require("guiconfig.inc");
33 5b237745 Scott Ullrich
34
$if = $_GET['if'];
35
if ($_POST['if'])
36
	$if = $_POST['if'];
37 e9f147c8 Scott Ullrich
38 11bc553c Scott Ullrich
/* if OLSRD is enabled, allow WAN to house DHCP. */
39 a3b466b5 Scott Ullrich
if($config['installedpackages']['olsrd']) {
40
	foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
41 bc15a1b9 Scott Ullrich
			if($olsrd['enable']) {
42 a3b466b5 Scott Ullrich
				$iflist = array("lan" => "LAN", "wan" => "WAN");
43 48ab0cd2 Scott Ullrich
				$is_olsr_enabled = true;
44 a3b466b5 Scott Ullrich
				break;
45
			}
46
	}
47 11bc553c Scott Ullrich
}
48
49
if(!$iflist)
50
	$iflist = array("lan" => "LAN");
51 5b237745 Scott Ullrich
52
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
53
	$oc = $config['interfaces']['opt' . $i];
54 e9f147c8 Scott Ullrich
55 5b237745 Scott Ullrich
	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 31c59d0d Scott Ullrich
$pconfig['gateway'] = $config['dhcpd'][$if]['gateway'];
68 5b237745 Scott Ullrich
list($pconfig['wins1'],$pconfig['wins2']) = $config['dhcpd'][$if]['winsserver'];
69 06d754d4 Scott Ullrich
list($pconfig['dns1'],$pconfig['dns2']) = $config['dhcpd'][$if]['dnsserver'];
70 5b237745 Scott Ullrich
$pconfig['enable'] = isset($config['dhcpd'][$if]['enable']);
71
$pconfig['denyunknown'] = isset($config['dhcpd'][$if]['denyunknown']);
72 80933129 Bill Marquette
$pconfig['staticarp'] = isset($config['dhcpd'][$if]['staticarp']);
73 4e9cd828 Seth Mos
$pconfig['ddnsdomain'] = $config['dhcpd'][$if]['ddnsdomain'];
74
$pconfig['ddnsupdate'] = isset($config['dhcpd'][$if]['ddnsupdate']);
75 37380063 Seth Mos
list($pconfig['ntp1'],$pconfig['ntp2']) = $config['dhcpd'][$if]['ntpserver'];
76 4e9cd828 Seth Mos
$pconfig['netboot'] = isset($config['dhcpd'][$if]['netboot']);
77
$pconfig['nextserver'] = $config['dhcpd'][$if]['next-server'];
78
$pconfig['filename'] = $config['dhcpd'][$if]['filename'];
79 ea166a33 Scott Ullrich
$pconfig['failover_peerip'] = $config['dhcpd'][$if]['failover_peerip'];
80 48ab0cd2 Scott Ullrich
$pconfig['netmask'] = $config['dhcpd'][$if]['netmask'];
81 31c59d0d Scott Ullrich
82 5b237745 Scott Ullrich
$ifcfg = $config['interfaces'][$if];
83
84 f6db0eef Chris Buechler
/*   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 602ebee3 Scott Ullrich
if (!is_array($config['dhcpd'][$if]['staticmap'])) {
104
	$config['dhcpd'][$if]['staticmap'] = array();
105
}
106
staticmaps_sort($if);
107 5b237745 Scott Ullrich
$a_maps = &$config['dhcpd'][$if]['staticmap'];
108 6f5b2c3e Scott Ullrich
109 0ea7462d Bill Marquette
function is_inrange($test, $start, $end) {
110 dd5b2ec6 Bill Marquette
	if ( (ip2long($test) < ip2long($end)) && (ip2long($test) > ip2long($start)) )
111 0ea7462d Bill Marquette
		return true;
112
	else
113
		return false;
114
}
115 b7597d4e Bill Marquette
116 5b237745 Scott Ullrich
if ($_POST) {
117
118
	unset($input_errors);
119 b7597d4e Bill Marquette
120 5b237745 Scott Ullrich
	$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 e9f147c8 Scott Ullrich
127 5b237745 Scott Ullrich
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
128 0ea7462d Bill Marquette
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 e9f147c8 Scott Ullrich
136 5b237745 Scott Ullrich
		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 6a01ea44 Bill Marquette
		if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
143 f9261419 Bill Marquette
			$input_errors[] = "A valid IP address must be specified for the gateway.";
144 6a01ea44 Bill Marquette
		}
145 5b237745 Scott Ullrich
		if (($_POST['wins1'] && !is_ipaddr($_POST['wins1'])) || ($_POST['wins2'] && !is_ipaddr($_POST['wins2']))) {
146 4cab31d0 Scott Ullrich
			$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 5b237745 Scott Ullrich
		}
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 4e9cd828 Seth Mos
		if (($_POST['ddnsdomain'] && !is_domain($_POST['ddnsdomain']))) {
158
			$input_errors[] = "A valid domain name must be specified for the dynamic DNS registration.";
159
		}
160 37380063 Seth Mos
		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 4e9cd828 Seth Mos
		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 e9f147c8 Scott Ullrich
168 5b237745 Scott Ullrich
		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 e9f147c8 Scott Ullrich
173 5b237745 Scott Ullrich
			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 e9f147c8 Scott Ullrich
				$input_errors[] = "The specified range lies outside of the current subnet.";
176 5b237745 Scott Ullrich
			}
177 e9f147c8 Scott Ullrich
178 5b237745 Scott Ullrich
			if (ip2long($_POST['range_from']) > ip2long($_POST['range_to']))
179
				$input_errors[] = "The range is invalid (first element higher than second element).";
180 e9f147c8 Scott Ullrich
181 5b237745 Scott Ullrich
			/* 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 48ab0cd2 Scott Ullrich
		$config['dhcpd'][$if]['netmask'] = $_POST['netmask'];
193 d378c59b Scott Ullrich
		$previous = $config['dhcpd'][$if]['failover_peerip'];
194
		if($previous <> $_POST['failover_peerip']) {
195 e9f147c8 Scott Ullrich
			mwexec("rm -rf /var/dhcpd/var/db/*");
196
		}
197 ea166a33 Scott Ullrich
		$config['dhcpd'][$if]['failover_peerip'] = $_POST['failover_peerip'];
198 e9f147c8 Scott Ullrich
199 5b237745 Scott Ullrich
		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 4cab31d0 Scott Ullrich
205 94a9cf1a Scott Ullrich
		unset($config['dhcpd'][$if]['dnsserver']);
206 e9f147c8 Scott Ullrich
		if ($_POST['dns1'])
207 06d754d4 Scott Ullrich
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns1'];
208 e9f147c8 Scott Ullrich
		if ($_POST['dns2'])
209 06d754d4 Scott Ullrich
			$config['dhcpd'][$if]['dnsserver'][] = $_POST['dns2'];
210 e9f147c8 Scott Ullrich
211 f9261419 Bill Marquette
		$config['dhcpd'][$if]['gateway'] = $_POST['gateway'];
212 6a01ea44 Bill Marquette
		$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 4e9cd828 Seth Mos
		$config['dhcpd'][$if]['ddnsdomain'] = $_POST['ddnsdomain'];
216
		$config['dhcpd'][$if]['ddnsupdate'] = ($_POST['ddnsupdate']) ? true : false;
217 37380063 Seth Mos
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 4e9cd828 Seth Mos
		$config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false;
225
		$config['dhcpd'][$if]['next-server'] = $_POST['nextserver'];
226
		$config['dhcpd'][$if]['filename'] = $_POST['filename'];
227 9c748b70 Scott Ullrich
228 5b237745 Scott Ullrich
		write_config();
229 80933129 Bill Marquette
230
		/* static arp configuration */
231 c5a0fd3c Scott Ullrich
		interfaces_staticarp_configure($if);
232 e9f147c8 Scott Ullrich
233 5b237745 Scott Ullrich
		$retval = 0;
234 6a01ea44 Bill Marquette
		$retvaldhcp = 0;
235
		$retvaldns = 0;
236 824edb6c Scott Ullrich
		config_lock();
237 6a01ea44 Bill Marquette
		/* 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 824edb6c Scott Ullrich
		config_unlock();
255 6a01ea44 Bill Marquette
		if($retvaldhcp == 1 || $retvaldns == 1)
256
			$retval = 1;
257 5b237745 Scott Ullrich
		$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 6a01ea44 Bill Marquette
		if(isset($config['dhcpd'][$if]['enable'])) {
266
			touch($d_staticmapsdirty_path);
267
			if (isset($config['dnsmasq']['regdhcpstatic']))
268
				touch($d_hostsdirty_path);
269
		}
270 5b237745 Scott Ullrich
		header("Location: services_dhcp.php?if={$if}");
271
		exit;
272
	}
273
}
274 4df96eff Scott Ullrich
275
$pgtitle = "Services: DHCP server";
276
include("head.inc");
277
278 5b237745 Scott Ullrich
?>
279 4df96eff Scott Ullrich
280 4e9cd828 Seth Mos
<script type="text/javascript" language="JavaScript">
281
282 5b237745 Scott Ullrich
function enable_change(enable_over) {
283 07bd3f83 Scott Ullrich
	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 4cab31d0 Scott Ullrich
	document.iform.dns1.disabled = endis;
290
	document.iform.dns2.disabled = endis;
291 07bd3f83 Scott Ullrich
	document.iform.deftime.disabled = endis;
292
	document.iform.maxtime.disabled = endis;
293 f9261419 Bill Marquette
	document.iform.gateway.disabled = endis;
294 fcffbd13 Scott Ullrich
	document.iform.failover_peerip.disabled = endis;
295 db6b2be4 Scott Ullrich
	document.iform.staticarp.disabled = endis;
296 4e9cd828 Seth Mos
	document.iform.ddnsdomain.disabled = endis;
297
	document.iform.ddnsupdate.disabled = endis;
298 37380063 Seth Mos
	document.iform.ntp1.disabled = endis;
299
	document.iform.ntp2.disabled = endis;
300 4e9cd828 Seth Mos
	document.iform.netboot.disabled = endis;
301
	document.iform.nextserver.disabled = endis;
302
	document.iform.filename.disabled = endis;
303 7ceb4368 Scott Ullrich
	document.iform.denyunknown.disabled = endis;
304 5b237745 Scott Ullrich
}
305 4e9cd828 Seth Mos
306
function show_ddns_config() {
307
	document.getElementById("showddnsbox").innerHTML='';
308
	aodiv = document.getElementById('showddns');
309
	aodiv.style.display = "block";
310
}
311
312 37380063 Seth Mos
function show_ntp_config() {
313
	document.getElementById("showntpbox").innerHTML='';
314
	aodiv = document.getElementById('showntp');
315
	aodiv.style.display = "block";
316
}
317
318 4e9cd828 Seth Mos
function show_netboot_config() {
319
	document.getElementById("shownetbootbox").innerHTML='';
320
	aodiv = document.getElementById('shownetboot');
321
	aodiv.style.display = "block";
322
}
323
324 5b237745 Scott Ullrich
</script>
325
326
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
327 b7597d4e Bill Marquette
<?php include("fbegin.inc"); ?>
328 74f446e8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
329 5b237745 Scott Ullrich
<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 f6db0eef Chris Buechler
<?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 5b237745 Scott Ullrich
<?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 f0cdf141 Scott Ullrich
  <?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 5b237745 Scott Ullrich
  </td></tr>
361 e9f147c8 Scott Ullrich
  <tr>
362 d732f186 Bill Marquette
    <td>
363
	<div id="mainarea">
364
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
365 e9f147c8 Scott Ullrich
                      <tr>
366 5b237745 Scott Ullrich
                        <td width="22%" valign="top" class="vtable">&nbsp;</td>
367
                        <td width="78%" class="vtable">
368 8c65eb75 Scott Ullrich
			  <input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
369 e9f147c8 Scott Ullrich
                          <strong>Enable DHCP server on
370 5b237745 Scott Ullrich
                          <?=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 8c65eb75 Scott Ullrich
			<input name="denyunknown" id="denyunknown" type="checkbox" value="yes" <?php if ($pconfig['denyunknown']) echo "checked"; ?>>
377 5b237745 Scott Ullrich
                      <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 e9f147c8 Scott Ullrich
                      <tr>
381 5b237745 Scott Ullrich
                        <td width="22%" valign="top" class="vncellreq">Subnet</td>
382 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
383 5b237745 Scott Ullrich
                          <?=gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']);?>
384
                        </td>
385
                      </tr>
386 e9f147c8 Scott Ullrich
                      <tr>
387
                        <td width="22%" valign="top" class="vncellreq">Subnet
388 5b237745 Scott Ullrich
                          mask</td>
389 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
390 5b237745 Scott Ullrich
                          <?=gen_subnet_mask($ifcfg['subnet']);?>
391
                        </td>
392
                      </tr>
393 e9f147c8 Scott Ullrich
                      <tr>
394
                        <td width="22%" valign="top" class="vncellreq">Available
395 5b237745 Scott Ullrich
                          range</td>
396 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
397 5b237745 Scott Ullrich
                          <?=long2ip(ip2long($ifcfg['ipaddr']) & gen_subnet_mask_long($ifcfg['subnet']));?>
398 e9f147c8 Scott Ullrich
                          -
399 5b237745 Scott Ullrich
                          <?=long2ip(ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet']))); ?>
400
                        </td>
401
                      </tr>
402 48ab0cd2 Scott Ullrich
					  <?php if($is_olsr_enabled): ?>
403 e9f147c8 Scott Ullrich
                      <tr>
404 48ab0cd2 Scott Ullrich
                        <td width="22%" valign="top" class="vncellreq">Subnet Mask</td>
405 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
406 48ab0cd2 Scott Ullrich
	                        <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 b1b09e34 Scott Ullrich
									if ($i == $pconfig['netmask']) echo "selected";
412 48ab0cd2 Scott Ullrich
									echo ">" . $i . "</option>";
413
								}
414
							}
415
							?>
416
							</select>
417
                        </td>
418
                      </tr>
419 e9f147c8 Scott Ullrich
                      <?php endif; ?>
420
                      <tr>
421 5b237745 Scott Ullrich
                        <td width="22%" valign="top" class="vncellreq">Range</td>
422 e9f147c8 Scott Ullrich
                        <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 25e031a1 Scott Ullrich
                          &nbsp;to&nbsp; <input name="range_to" type="text" class="formfld" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>">
425
			</td>
426 5b237745 Scott Ullrich
                      </tr>
427 e9f147c8 Scott Ullrich
                      <tr>
428 5b237745 Scott Ullrich
                        <td width="22%" valign="top" class="vncell">WINS servers</td>
429 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
430 5b237745 Scott Ullrich
                          <input name="wins1" type="text" class="formfld" id="wins1" size="20" value="<?=htmlspecialchars($pconfig['wins1']);?>"><br>
431 25e031a1 Scott Ullrich
                          <input name="wins2" type="text" class="formfld" id="wins2" size="20" value="<?=htmlspecialchars($pconfig['wins2']);?>">
432
			</td>
433 5b237745 Scott Ullrich
                      </tr>
434 e9f147c8 Scott Ullrich
                      <tr>
435 4cab31d0 Scott Ullrich
                        <td width="22%" valign="top" class="vncell">DNS servers</td>
436 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
437 4cab31d0 Scott Ullrich
                          <input name="dns1" type="text" class="formfld" id="dns1" size="20" value="<?=htmlspecialchars($pconfig['dns1']);?>"><br>
438 25e031a1 Scott Ullrich
                          <input name="dns2" type="text" class="formfld" id="dns2" size="20" value="<?=htmlspecialchars($pconfig['dns2']);?>"><br>
439 7e74b5bf Chris Buechler
			  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 25e031a1 Scott Ullrich
			</td>
441 4cab31d0 Scott Ullrich
                      </tr>
442 e9f147c8 Scott Ullrich
                     <tr>
443 b7597d4e Bill Marquette
                       <td width="22%" valign="top" class="vncell">Gateway</td>
444 e9f147c8 Scott Ullrich
                       <td width="78%" class="vtable">
445 b7597d4e Bill Marquette
                         <input name="gateway" type="text" class="formfld" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>"><br>
446 7e74b5bf Chris Buechler
			 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 e9f147c8 Scott Ullrich
			</td>
448 2af4c579 Scott Ullrich
                     </tr>
449 e9f147c8 Scott Ullrich
                      <tr>
450
                        <td width="22%" valign="top" class="vncell">Default lease
451 5b237745 Scott Ullrich
                          time</td>
452 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
453 5b237745 Scott Ullrich
                          <input name="deftime" type="text" class="formfld" id="deftime" size="10" value="<?=htmlspecialchars($pconfig['deftime']);?>">
454
                          seconds<br>
455 e9f147c8 Scott Ullrich
                          This is used for clients that do not ask for a specific
456 5b237745 Scott Ullrich
                          expiration time.<br>
457 2af4c579 Scott Ullrich
                          The default is 7200 seconds.
458
			</td>
459 5b237745 Scott Ullrich
                      </tr>
460 e9f147c8 Scott Ullrich
                      <tr>
461
                        <td width="22%" valign="top" class="vncell">Maximum lease
462 5b237745 Scott Ullrich
                          time</td>
463 e9f147c8 Scott Ullrich
                        <td width="78%" class="vtable">
464 5b237745 Scott Ullrich
                          <input name="maxtime" type="text" class="formfld" id="maxtime" size="10" value="<?=htmlspecialchars($pconfig['maxtime']);?>">
465
                          seconds<br>
466 e9f147c8 Scott Ullrich
                          This is the maximum lease time for clients that ask
467 5b237745 Scott Ullrich
                          for a specific expiration time.<br>
468 2af4c579 Scott Ullrich
                          The default is 86400 seconds.
469
			</td>
470 5b237745 Scott Ullrich
                      </tr>
471 ea166a33 Scott Ullrich
                      <tr>
472
                        <td width="22%" valign="top" class="vncell">Failover peer IP:</td>
473
                        <td width="78%" class="vtable">
474 4e9cd828 Seth Mos
				<input name="failover_peerip" type="text" class="formfld" id="failover_peerip" size="20" value="<?=htmlspecialchars($pconfig['failover_peerip']);?>"><br>
475 be586e5f Scott Ullrich
				Leave blank to disable.  Enter the REAL address of the other machine.  Machines must be using CARP.
476 ea166a33 Scott Ullrich
			</td>
477
		      </tr>
478 f1da88f6 Bill Marquette
                      <tr>
479
                        <td width="22%" valign="top" class="vncell">Static ARP</td>
480 e44a0096 Scott Ullrich
                        <td width="78%" class="vtable">
481
				<table>
482 2af4c579 Scott Ullrich
					<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 c5a0fd3c Scott Ullrich
							<span class="red"><strong>Note:</strong></span> Only the machines listed below will be able to communicate with the firewall on this NIC.
496 2af4c579 Scott Ullrich
						</td>
497
					</tr>
498 e44a0096 Scott Ullrich
				</table>
499
			</td>
500 f1da88f6 Bill Marquette
                      </tr>
501 4e9cd828 Seth Mos
                      <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 37380063 Seth Mos
                      <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 4e9cd828 Seth Mos
                      <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 e9f147c8 Scott Ullrich
                      <tr>
549 5b237745 Scott Ullrich
                        <td width="22%" valign="top">&nbsp;</td>
550 e9f147c8 Scott Ullrich
                        <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 5b237745 Scott Ullrich
                        </td>
554
                      </tr>
555 e9f147c8 Scott Ullrich
                      <tr>
556 5b237745 Scott Ullrich
                        <td width="22%" valign="top">&nbsp;</td>
557
                        <td width="78%"> <p><span class="vexpl"><span class="red"><strong>Note:<br>
558 e9f147c8 Scott Ullrich
                            </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 5b237745 Scott Ullrich
                            be assigned to clients by the DHCP server.<br>
562
                            <br>
563 2c7da080 Scott Ullrich
                            The DHCP lease table can be viewed on the <a href="diag_dhcp_leases.php">Status:
564 5b237745 Scott Ullrich
                            DHCP leases</a> page.<br>
565 2af4c579 Scott Ullrich
                            </span></p>
566
			</td>
567 5b237745 Scott Ullrich
                      </tr>
568
                    </table>
569 d732f186 Bill Marquette
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
570 5b237745 Scott Ullrich
                <tr>
571 6a01ea44 Bill Marquette
                  <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 2af4c579 Scott Ullrich
                  <td width="10%" class="list">
576 05c90549 Seth Mos
                    <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 2af4c579 Scott Ullrich
		  </td>
583
		</tr>
584 6f5b2c3e Scott Ullrich
			  <?php if(is_array($a_maps)): ?>
585 5b237745 Scott Ullrich
			  <?php $i = 0; foreach ($a_maps as $mapent): ?>
586 11c9bb94 Scott Ullrich
			  <?php if($mapent['mac'] <> "" or $mapent['ipaddr'] <> ""): ?>
587 5b237745 Scott Ullrich
                <tr>
588 2d165eff Bill Marquette
                  <td class="listlr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
589 5b237745 Scott Ullrich
                    <?=htmlspecialchars($mapent['mac']);?>
590
                  </td>
591 2d165eff Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
592 5b237745 Scott Ullrich
                    <?=htmlspecialchars($mapent['ipaddr']);?>&nbsp;
593
                  </td>
594 6a01ea44 Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
595
                    <?=htmlspecialchars($mapent['hostname']);?>&nbsp;
596
                  </td>	
597 2d165eff Bill Marquette
                  <td class="listbg" ondblclick="document.location='services_dhcp_edit.php?if=<?=$if;?>&id=<?=$i;?>';">
598 588b7fc5 Bill Marquette
                    <font color="#FFFFFF"><?=htmlspecialchars($mapent['descr']);?>&nbsp;</font>
599 5b237745 Scott Ullrich
                  </td>
600 75a70796 Bill Marquette
                  <td valign="middle" nowrap class="list">
601
                    <table border="0" cellspacing="0" cellpadding="1">
602
                      <tr>
603 677c0869 Erik Kristensen
                        <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 75a70796 Bill Marquette
                      </tr>
606
                    </table>
607
                  </td>
608
                </tr>
609 6f5b2c3e Scott Ullrich
		<?php endif; ?>
610 75a70796 Bill Marquette
		<?php $i++; endforeach; ?>
611 6f5b2c3e Scott Ullrich
		<?php endif; ?>
612 e9f147c8 Scott Ullrich
                <tr>
613 6a01ea44 Bill Marquette
                  <td class="list" colspan="4"></td>
614 75a70796 Bill Marquette
                  <td class="list">
615
                    <table border="0" cellspacing="0" cellpadding="1">
616
                      <tr>
617 05c90549 Seth Mos
			<td valign="middle" width="17"></td>
618 677c0869 Erik Kristensen
                        <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 75a70796 Bill Marquette
                      </tr>
620
                    </table>
621
                  </td>
622
                </tr>
623 5b237745 Scott Ullrich
              </table>
624 d732f186 Bill Marquette
	</div>
625 5b237745 Scott Ullrich
    </td>
626
  </tr>
627
</table>
628
</form>
629
<script language="JavaScript">
630
<!--
631
enable_change(false);
632
//-->
633
</script>
634 b7597d4e Bill Marquette
<?php include("fend.inc"); ?>
635 5b237745 Scott Ullrich
</body>
636
</html>