1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
7f5b4824
|
Scott Ullrich
|
<?php
|
3 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
4 |
5b237745
|
Scott Ullrich
|
/*
|
5 |
|
|
interfaces_lan.php
|
6 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
7 |
7f5b4824
|
Scott Ullrich
|
|
8 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
9 |
|
|
All rights reserved.
|
10 |
7f5b4824
|
Scott Ullrich
|
|
11 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, are permitted provided that the following conditions are met:
|
13 |
7f5b4824
|
Scott Ullrich
|
|
14 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
this list of conditions and the following disclaimer.
|
16 |
7f5b4824
|
Scott Ullrich
|
|
17 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
7f5b4824
|
Scott Ullrich
|
|
21 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
|
|
*/
|
32 |
|
|
|
33 |
|
|
require("guiconfig.inc");
|
34 |
|
|
|
35 |
|
|
$lancfg = &$config['interfaces']['lan'];
|
36 |
d9a31e93
|
Scott Ullrich
|
$optcfg = &$config['interfaces']['lan'];
|
37 |
|
|
|
38 |
e95c754f
|
Bill Marquette
|
$pconfig['ipaddr'] = $lancfg['ipaddr'];
|
39 |
|
|
$pconfig['subnet'] = $lancfg['subnet'];
|
40 |
05aa1128
|
Scott Ullrich
|
$pconfig['bridge'] = $lancfg['bridge'];
|
41 |
e95c754f
|
Bill Marquette
|
$pconfig['bandwidth'] = $lancfg['bandwidth'];
|
42 |
|
|
$pconfig['bandwidthtype'] = $lancfg['bandwidthtype'];
|
43 |
03b92764
|
Scott Ullrich
|
|
44 |
5b237745
|
Scott Ullrich
|
/* Wireless interface? */
|
45 |
b7f01f59
|
Bill Marquette
|
if (isset($lancfg['wireless'])) {
|
46 |
5b237745
|
Scott Ullrich
|
require("interfaces_wlan.inc");
|
47 |
|
|
wireless_config_init();
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
if ($_POST) {
|
51 |
|
|
|
52 |
6d6d0f14
|
Scott Ullrich
|
if ($_POST['bridge']) {
|
53 |
|
|
/* double bridging? */
|
54 |
|
|
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
|
55 |
|
|
if ($i != $index) {
|
56 |
|
|
if ($config['interfaces']['opt' . $i]['bridge'] == $_POST['bridge']) {
|
57 |
4ab4e4ef
|
Scott Ullrich
|
//$input_errors[] = "Optional interface {$i} " .
|
58 |
|
|
// "({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
|
59 |
|
|
// "the specified interface.";
|
60 |
6d6d0f14
|
Scott Ullrich
|
} else if ($config['interfaces']['opt' . $i]['bridge'] == "opt{$index}") {
|
61 |
4ab4e4ef
|
Scott Ullrich
|
//$input_errors[] = "Optional interface {$i} " .
|
62 |
|
|
// "({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
|
63 |
|
|
// "this interface.";
|
64 |
6d6d0f14
|
Scott Ullrich
|
}
|
65 |
|
|
}
|
66 |
5b237745
|
Scott Ullrich
|
}
|
67 |
6d6d0f14
|
Scott Ullrich
|
if ($config['interfaces'][$_POST['bridge']]['bridge']) {
|
68 |
19c0f3b3
|
Scott Ullrich
|
//$input_errors[] = "The specified interface is already bridged to " .
|
69 |
|
|
// "another interface.";
|
70 |
52442f57
|
Bill Marquette
|
}
|
71 |
6d6d0f14
|
Scott Ullrich
|
/* captive portal on? */
|
72 |
|
|
if (isset($config['captiveportal']['enable'])) {
|
73 |
19c0f3b3
|
Scott Ullrich
|
//$input_errors[] = "Interfaces cannot be bridged while the captive portal is enabled.";
|
74 |
001fdeea
|
Scott Ullrich
|
}
|
75 |
75211081
|
Scott Ullrich
|
}
|
76 |
|
|
|
77 |
|
|
unset($input_errors);
|
78 |
|
|
$pconfig = $_POST;
|
79 |
|
|
$changedesc = "LAN Interface: ";
|
80 |
|
|
|
81 |
|
|
/* input validation */
|
82 |
b85311ed
|
Scott Ullrich
|
if (!$_POST['bridge']) {
|
83 |
|
|
$reqdfields = explode(" ", "ipaddr subnet");
|
84 |
|
|
$reqdfieldsn = explode(",", "IP address,Subnet bit count");
|
85 |
ac671944
|
Scott Ullrich
|
|
86 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
87 |
b85311ed
|
Scott Ullrich
|
}
|
88 |
75211081
|
Scott Ullrich
|
|
89 |
|
|
if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
|
90 |
|
|
$input_errors[] = "A valid IP address must be specified.";
|
91 |
|
|
}
|
92 |
|
|
if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
|
93 |
|
|
$input_errors[] = "A valid subnet bit count must be specified.";
|
94 |
|
|
}
|
95 |
0138d492
|
Scott Ullrich
|
if($_POST['bandwidth'] <> "" && !is_numeric($_POST['bandwidth'])) {
|
96 |
|
|
$input_errors[] = "A valid bandwidth value is required 1-999999.";
|
97 |
|
|
}
|
98 |
75211081
|
Scott Ullrich
|
|
99 |
|
|
/* Wireless interface? */
|
100 |
|
|
if (isset($lancfg['wireless'])) {
|
101 |
|
|
$wi_input_errors = wireless_config_post();
|
102 |
|
|
if ($wi_input_errors) {
|
103 |
|
|
$input_errors = array_merge($input_errors, $wi_input_errors);
|
104 |
6d6d0f14
|
Scott Ullrich
|
}
|
105 |
75211081
|
Scott Ullrich
|
}
|
106 |
|
|
|
107 |
|
|
if (!$input_errors) {
|
108 |
8f33c905
|
Scott Ullrich
|
|
109 |
|
|
$lancfg['bridge'] = $_POST['bridge'];
|
110 |
|
|
|
111 |
75211081
|
Scott Ullrich
|
if (($lancfg['ipaddr'] != $_POST['ipaddr']) || ($lancfg['subnet'] != $_POST['subnet'])) {
|
112 |
|
|
update_if_changed("IP Address", &$lancfg['ipaddr'], $_POST['ipaddr']);
|
113 |
|
|
update_if_changed("subnet", &$lancfg['subnet'], $_POST['subnet']);
|
114 |
6d6d0f14
|
Scott Ullrich
|
}
|
115 |
75211081
|
Scott Ullrich
|
|
116 |
|
|
if($_POST['bandwidth'] <> "" and $_POST['bandwidthtype'] <> "") {
|
117 |
|
|
update_if_changed("bandwidth", &$lancfg['bandwidth'], $_POST['bandwidth']);
|
118 |
|
|
update_if_changed("bandwidth type", &$lancfg['bandwidthtype'], $_POST['bandwidthtype']);
|
119 |
|
|
} else {
|
120 |
|
|
unset($lancfg['bandwidth']);
|
121 |
|
|
unset($lancfg['bandwidthtype']);
|
122 |
6d6d0f14
|
Scott Ullrich
|
}
|
123 |
75211081
|
Scott Ullrich
|
|
124 |
|
|
write_config($changedesc);
|
125 |
|
|
|
126 |
03e6d007
|
Scott Ullrich
|
touch($d_landirty_path);
|
127 |
|
|
|
128 |
f88a634b
|
Scott Ullrich
|
if ($_POST['apply'] <> "") {
|
129 |
|
|
unlink($d_landirty_path);
|
130 |
75211081
|
Scott Ullrich
|
$savemsg = "The changes have been applied. You may need to correct the web browsers ip address.";
|
131 |
03e6d007
|
Scott Ullrich
|
}
|
132 |
|
|
|
133 |
5b237745
|
Scott Ullrich
|
}
|
134 |
|
|
}
|
135 |
222b5299
|
Scott Ullrich
|
|
136 |
b9e255dd
|
Bill Marquette
|
|
137 |
7f43ca88
|
Scott Ullrich
|
$pgtitle = "Interfaces: LAN";
|
138 |
|
|
include("head.inc");
|
139 |
|
|
|
140 |
|
|
?>
|
141 |
b9e255dd
|
Bill Marquette
|
<script type="text/javascript" language="javascript" src="ip_helper.js">
|
142 |
|
|
</script>
|
143 |
|
|
|
144 |
5b237745
|
Scott Ullrich
|
<script language="JavaScript">
|
145 |
|
|
<!--
|
146 |
|
|
function ipaddr_change() {
|
147 |
6846116e
|
Scott Ullrich
|
document.iform.subnet.value = gen_bits_lan(document.iform.ipaddr.value);
|
148 |
5b237745
|
Scott Ullrich
|
}
|
149 |
6d6d0f14
|
Scott Ullrich
|
function enable_change(enable_over) {
|
150 |
ac671944
|
Scott Ullrich
|
return;
|
151 |
6d6d0f14
|
Scott Ullrich
|
var endis;
|
152 |
|
|
endis = !((document.iform.bridge.selectedIndex == 0) || enable_over);
|
153 |
|
|
document.iform.ipaddr.disabled = endis;
|
154 |
|
|
document.iform.subnet.disabled = endis;
|
155 |
|
|
}
|
156 |
5b237745
|
Scott Ullrich
|
// -->
|
157 |
|
|
</script>
|
158 |
b9e255dd
|
Bill Marquette
|
|
159 |
5b237745
|
Scott Ullrich
|
|
160 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
161 |
f88a634b
|
Scott Ullrich
|
<form action="interfaces_lan.php" method="post" name="iform" id="iform">
|
162 |
5b237745
|
Scott Ullrich
|
<?php include("fbegin.inc"); ?>
|
163 |
931066a8
|
Bill Marquette
|
<p class="pgtitle"><?=$pgtitle?></p>
|
164 |
5b237745
|
Scott Ullrich
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
165 |
03e6d007
|
Scott Ullrich
|
<?php if (file_exists($d_landirty_path)): ?><p>
|
166 |
17faca58
|
Scott Ullrich
|
<?php print_info_box_np("The LAN configuration has been changed.<p>You must apply the changes in order for them to take effect.<p>Don't forget to adjust the DHCP Server range if needed before applying.");?><br>
|
167 |
03e6d007
|
Scott Ullrich
|
<?php endif; ?>
|
168 |
bf158f5c
|
Scott Ullrich
|
<?php if ($savemsg) print_info_box_np($savemsg); ?>
|
169 |
5b237745
|
Scott Ullrich
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
170 |
5b80d869
|
Scott Ullrich
|
<tr>
|
171 |
|
|
<td colspan="2" valign="top" class="listtopic">IP configuration</td>
|
172 |
|
|
</tr>
|
173 |
6d6d0f14
|
Scott Ullrich
|
<tr>
|
174 |
|
|
<td width="22%" valign="top" class="vncellreq">Bridge with</td>
|
175 |
|
|
<td width="78%" class="vtable">
|
176 |
|
|
<select name="bridge" class="formfld" id="bridge" onChange="enable_change(false)">
|
177 |
|
|
<option <?php if (!$pconfig['bridge']) echo "selected";?> value="">none</option>
|
178 |
|
|
<?php $opts = array('lan' => "LAN", 'wan' => "WAN");
|
179 |
|
|
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
|
180 |
|
|
if ($i != $index)
|
181 |
|
|
$opts['opt' . $i] = "Optional " . $i . " (" .
|
182 |
|
|
$config['interfaces']['opt' . $i]['descr'] . ")";
|
183 |
|
|
}
|
184 |
|
|
foreach ($opts as $opt => $optname): ?>
|
185 |
|
|
<option <?php if ($opt == $pconfig['bridge']) echo "selected";?> value="<?=htmlspecialchars($opt);?>">
|
186 |
|
|
<?=htmlspecialchars($optname);?>
|
187 |
|
|
</option>
|
188 |
|
|
<?php endforeach; ?>
|
189 |
|
|
</select> </td>
|
190 |
|
|
</tr>
|
191 |
7f5b4824
|
Scott Ullrich
|
<tr>
|
192 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">IP address</td>
|
193 |
7f5b4824
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
194 |
5b237745
|
Scott Ullrich
|
<input name="ipaddr" type="text" class="formfld" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" onchange="ipaddr_change()">
|
195 |
7f5b4824
|
Scott Ullrich
|
/
|
196 |
5b237745
|
Scott Ullrich
|
<select name="subnet" class="formfld" id="subnet">
|
197 |
21ab1cde
|
Scott Ullrich
|
<?php
|
198 |
|
|
for ($i = 32; $i > 0; $i--) {
|
199 |
|
|
if($i <> 31) {
|
200 |
|
|
echo "<option value=\"{$i}\" ";
|
201 |
|
|
if ($i == $pconfig['subnet']) echo "selected";
|
202 |
|
|
echo ">" . $i . "</option>";
|
203 |
|
|
}
|
204 |
|
|
}
|
205 |
|
|
?>
|
206 |
5b237745
|
Scott Ullrich
|
</select></td>
|
207 |
|
|
</tr>
|
208 |
|
|
<?php /* Wireless interface? */
|
209 |
b7f01f59
|
Bill Marquette
|
if (isset($lancfg['wireless']))
|
210 |
5b237745
|
Scott Ullrich
|
wireless_config_print();
|
211 |
|
|
?>
|
212 |
73c38fa2
|
Scott Ullrich
|
|
213 |
|
|
<tr>
|
214 |
|
|
<td colspan="2" valign="top" height="16"></td>
|
215 |
|
|
</tr>
|
216 |
|
|
|
217 |
|
|
<tr>
|
218 |
|
|
<td colspan="2" valign="top" class="vnsepcell">Bandwidth Management (Traffic Shaping)</td>
|
219 |
|
|
</tr>
|
220 |
7f5b4824
|
Scott Ullrich
|
<tr>
|
221 |
|
|
<td valign="top" class="vncell">Interface Bandwidth Speed</td>
|
222 |
|
|
<td class="vtable"> <input name="bandwidth" type="text" class="formfld" id="bandwidth" size="30" value="<?=htmlspecialchars($pconfig['bandwidth']);?>">
|
223 |
|
|
<select name="bandwidthtype">
|
224 |
|
|
<option value="<?=htmlspecialchars($pconfig['bandwidthtype']);?>"><?=htmlspecialchars($pconfig['bandwidthtype']);?></option>
|
225 |
|
|
<option value="b">bit/s</option>
|
226 |
|
|
<option value="Kb">Kilobit/s</option>
|
227 |
|
|
<option value="Mb">Megabit/s</option>
|
228 |
|
|
<option value="Gb">Gigabit/s</option>
|
229 |
d09c8936
|
Scott Ullrich
|
<option value=""></option>
|
230 |
7f5b4824
|
Scott Ullrich
|
</select>
|
231 |
ac3c2b2a
|
Scott Ullrich
|
<br> The bandwidth setting will define the speed of the interface for traffic shaping. Do not enter your "Internet" bandwidth here, only the physical speed!
|
232 |
7f5b4824
|
Scott Ullrich
|
</td>
|
233 |
|
|
</tr>
|
234 |
|
|
<tr>
|
235 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
236 |
7f5b4824
|
Scott Ullrich
|
<td width="78%">
|
237 |
|
|
<input name="Submit" type="submit" class="formbtn" value="Save">
|
238 |
5b237745
|
Scott Ullrich
|
</td>
|
239 |
|
|
</tr>
|
240 |
7f5b4824
|
Scott Ullrich
|
<tr>
|
241 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
242 |
|
|
<td width="78%"><span class="vexpl"><span class="red"><strong>Warning:<br>
|
243 |
0390c50a
|
Bill Marquette
|
</strong></span>after you click "Save", you will need
|
244 |
c55a8ab9
|
Holger Bauer
|
to do one or more of the following steps before you can
|
245 |
7f5b4824
|
Scott Ullrich
|
access your firewall again:
|
246 |
5b237745
|
Scott Ullrich
|
<ul>
|
247 |
|
|
<li>change the IP address of your computer</li>
|
248 |
|
|
<li>renew its DHCP lease</li>
|
249 |
|
|
<li>access the webGUI with the new IP address</li>
|
250 |
f0dcff6f
|
Scott Ullrich
|
<li>be sure to add <a href="firewall_rules.php">firewall rules</a> to permit traffic through the interface.</li>
|
251 |
|
|
<li>You also need firewall rules for an interface in bridged mode as the firewall acts as a filtering bridge.</li>
|
252 |
5b237745
|
Scott Ullrich
|
</ul>
|
253 |
|
|
</span></td>
|
254 |
|
|
</tr>
|
255 |
|
|
</table>
|
256 |
|
|
</form>
|
257 |
|
|
<?php include("fend.inc"); ?>
|
258 |
|
|
</body>
|
259 |
|
|
</html>
|
260 |
b5933544
|
Scott Ullrich
|
|
261 |
|
|
<?php
|
262 |
|
|
|
263 |
f88a634b
|
Scott Ullrich
|
if ($_POST['apply'] <> "") {
|
264 |
b5933544
|
Scott Ullrich
|
|
265 |
|
|
/* Change these items late in the script
|
266 |
|
|
* so the script will fully complete to
|
267 |
|
|
* the users web browser
|
268 |
|
|
*/
|
269 |
|
|
|
270 |
|
|
/* set up LAN interface */
|
271 |
|
|
interfaces_lan_configure();
|
272 |
|
|
|
273 |
|
|
interfaces_vlan_configure();
|
274 |
|
|
|
275 |
|
|
/* setup carp interfaces */
|
276 |
|
|
interfaces_carp_configure();
|
277 |
|
|
|
278 |
|
|
/* bring up carp interfaces */
|
279 |
03e6d007
|
Scott Ullrich
|
interfaces_carp_bringup();
|
280 |
|
|
|
281 |
|
|
unlink($d_landirty_path);
|
282 |
b5933544
|
Scott Ullrich
|
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
?>
|