1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
7f5b4824
|
Scott Ullrich
|
<?php
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
interfaces_lan.php
|
5 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
6 |
7f5b4824
|
Scott Ullrich
|
|
7 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
|
|
All rights reserved.
|
9 |
7f5b4824
|
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 |
7f5b4824
|
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 |
7f5b4824
|
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 |
7f5b4824
|
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 |
|
|
require("guiconfig.inc");
|
33 |
|
|
|
34 |
|
|
$lancfg = &$config['interfaces']['lan'];
|
35 |
|
|
$optcfg = &$config['interfaces']['lan'];
|
36 |
|
|
$pconfig['ipaddr'] = $config['interfaces']['lan']['ipaddr'];
|
37 |
|
|
$pconfig['subnet'] = $config['interfaces']['lan']['subnet'];
|
38 |
|
|
|
39 |
03b92764
|
Scott Ullrich
|
$pconfig['bandwidth'] = $config['interfaces']['lan']['bandwidth'];
|
40 |
|
|
$pconfig['bandwidthtype'] = $config['interfaces']['lan']['bandwidthtype'];
|
41 |
|
|
|
42 |
5b237745
|
Scott Ullrich
|
/* Wireless interface? */
|
43 |
|
|
if (isset($optcfg['wireless'])) {
|
44 |
|
|
require("interfaces_wlan.inc");
|
45 |
|
|
wireless_config_init();
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
if ($_POST) {
|
49 |
|
|
|
50 |
|
|
unset($input_errors);
|
51 |
|
|
$pconfig = $_POST;
|
52 |
|
|
|
53 |
|
|
/* input validation */
|
54 |
|
|
$reqdfields = explode(" ", "ipaddr subnet");
|
55 |
|
|
$reqdfieldsn = explode(",", "IP address,Subnet bit count");
|
56 |
7f5b4824
|
Scott Ullrich
|
|
57 |
5b237745
|
Scott Ullrich
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
58 |
7f5b4824
|
Scott Ullrich
|
|
59 |
5b237745
|
Scott Ullrich
|
if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
|
60 |
|
|
$input_errors[] = "A valid IP address must be specified.";
|
61 |
|
|
}
|
62 |
|
|
if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
|
63 |
|
|
$input_errors[] = "A valid subnet bit count must be specified.";
|
64 |
|
|
}
|
65 |
7f5b4824
|
Scott Ullrich
|
|
66 |
5b237745
|
Scott Ullrich
|
/* Wireless interface? */
|
67 |
|
|
if (isset($optcfg['wireless'])) {
|
68 |
|
|
$wi_input_errors = wireless_config_post();
|
69 |
|
|
if ($wi_input_errors) {
|
70 |
|
|
$input_errors = array_merge($input_errors, $wi_input_errors);
|
71 |
|
|
}
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
if (!$input_errors) {
|
75 |
|
|
$config['interfaces']['lan']['ipaddr'] = $_POST['ipaddr'];
|
76 |
|
|
$config['interfaces']['lan']['subnet'] = $_POST['subnet'];
|
77 |
7f5b4824
|
Scott Ullrich
|
$config['interfaces']['lan']['bandwidth'] = $_POST['bandwidth'];
|
78 |
|
|
$config['interfaces']['lan']['bandwidthtype'] = $_POST['bandwidthtype'];
|
79 |
|
|
|
80 |
5b237745
|
Scott Ullrich
|
$dhcpd_was_enabled = 0;
|
81 |
|
|
if (isset($config['dhcpd']['enable'])) {
|
82 |
|
|
unset($config['dhcpd']['enable']);
|
83 |
|
|
$dhcpd_was_enabled = 1;
|
84 |
|
|
}
|
85 |
7f5b4824
|
Scott Ullrich
|
|
86 |
5b237745
|
Scott Ullrich
|
write_config();
|
87 |
|
|
touch($d_sysrebootreqd_path);
|
88 |
7f5b4824
|
Scott Ullrich
|
|
89 |
5b237745
|
Scott Ullrich
|
$savemsg = get_std_save_message(0);
|
90 |
7f5b4824
|
Scott Ullrich
|
|
91 |
5b237745
|
Scott Ullrich
|
if ($dhcpd_was_enabled)
|
92 |
|
|
$savemsg .= "<br>Note that the DHCP server has been disabled.<br>Please review its configuration " .
|
93 |
|
|
"and enable it again prior to rebooting.";
|
94 |
|
|
}
|
95 |
|
|
}
|
96 |
222b5299
|
Scott Ullrich
|
|
97 |
5b237745
|
Scott Ullrich
|
?>
|
98 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
99 |
|
|
<html>
|
100 |
|
|
<head>
|
101 |
|
|
<title><?=gentitle("Interfaces: LAN");?></title>
|
102 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
103 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
104 |
|
|
<script language="JavaScript">
|
105 |
|
|
<!--
|
106 |
|
|
function gen_bits(ipaddr) {
|
107 |
|
|
if (ipaddr.search(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) != -1) {
|
108 |
|
|
var adr = ipaddr.split(/\./);
|
109 |
|
|
if (adr[0] > 255 || adr[1] > 255 || adr[2] > 255 || adr[3] > 255)
|
110 |
|
|
return "";
|
111 |
|
|
if (adr[0] == 0 && adr[1] == 0 && adr[2] == 0 && adr[3] == 0)
|
112 |
|
|
return "";
|
113 |
7f5b4824
|
Scott Ullrich
|
|
114 |
5b237745
|
Scott Ullrich
|
if (adr[0] <= 127)
|
115 |
|
|
return "8";
|
116 |
|
|
else if (adr[0] <= 191)
|
117 |
|
|
return "16";
|
118 |
|
|
else
|
119 |
|
|
return "24";
|
120 |
|
|
}
|
121 |
|
|
else
|
122 |
|
|
return "";
|
123 |
|
|
}
|
124 |
|
|
function ipaddr_change() {
|
125 |
|
|
document.iform.subnet.value = gen_bits(document.iform.ipaddr.value);
|
126 |
|
|
}
|
127 |
|
|
// -->
|
128 |
|
|
</script>
|
129 |
|
|
</head>
|
130 |
|
|
|
131 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
132 |
|
|
<?php include("fbegin.inc"); ?>
|
133 |
|
|
<p class="pgtitle">Interfaces: LAN</p>
|
134 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
135 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
136 |
|
|
<form action="interfaces_lan.php" method="post" name="iform" id="iform">
|
137 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
138 |
7f5b4824
|
Scott Ullrich
|
<tr>
|
139 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">IP address</td>
|
140 |
7f5b4824
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
141 |
5b237745
|
Scott Ullrich
|
<input name="ipaddr" type="text" class="formfld" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>" onchange="ipaddr_change()">
|
142 |
7f5b4824
|
Scott Ullrich
|
/
|
143 |
5b237745
|
Scott Ullrich
|
<select name="subnet" class="formfld" id="subnet">
|
144 |
21ab1cde
|
Scott Ullrich
|
<?php
|
145 |
|
|
for ($i = 32; $i > 0; $i--) {
|
146 |
|
|
if($i <> 31) {
|
147 |
|
|
echo "<option value=\"{$i}\" ";
|
148 |
|
|
if ($i == $pconfig['subnet']) echo "selected";
|
149 |
|
|
echo ">" . $i . "</option>";
|
150 |
|
|
}
|
151 |
|
|
}
|
152 |
|
|
?>
|
153 |
5b237745
|
Scott Ullrich
|
</select></td>
|
154 |
|
|
</tr>
|
155 |
|
|
<?php /* Wireless interface? */
|
156 |
|
|
if (isset($optcfg['wireless']))
|
157 |
|
|
wireless_config_print();
|
158 |
|
|
?>
|
159 |
73c38fa2
|
Scott Ullrich
|
|
160 |
|
|
<tr>
|
161 |
|
|
<td colspan="2" valign="top" height="16"></td>
|
162 |
|
|
</tr>
|
163 |
|
|
|
164 |
|
|
<tr>
|
165 |
|
|
<td colspan="2" valign="top" class="vnsepcell">Bandwidth Management (Traffic Shaping)</td>
|
166 |
|
|
</tr>
|
167 |
7f5b4824
|
Scott Ullrich
|
<tr>
|
168 |
|
|
<td valign="top" class="vncell">Interface Bandwidth Speed</td>
|
169 |
|
|
<td class="vtable"> <input name="bandwidth" type="text" class="formfld" id="bandwidth" size="30" value="<?=htmlspecialchars($pconfig['bandwidth']);?>">
|
170 |
|
|
<select name="bandwidthtype">
|
171 |
|
|
<option value="<?=htmlspecialchars($pconfig['bandwidthtype']);?>"><?=htmlspecialchars($pconfig['bandwidthtype']);?></option>
|
172 |
|
|
<option value="b">bit/s</option>
|
173 |
|
|
<option value="Kb">Kilobit/s</option>
|
174 |
|
|
<option value="Mb">Megabit/s</option>
|
175 |
|
|
<option value="Gb">Gigabit/s</option>
|
176 |
d09c8936
|
Scott Ullrich
|
<option value=""></option>
|
177 |
7f5b4824
|
Scott Ullrich
|
</select>
|
178 |
|
|
<br> The bandwidth setting will define the speed of the interface for traffic shaping.
|
179 |
|
|
</td>
|
180 |
|
|
</tr>
|
181 |
|
|
<tr>
|
182 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
183 |
7f5b4824
|
Scott Ullrich
|
<td width="78%">
|
184 |
|
|
<input name="Submit" type="submit" class="formbtn" value="Save">
|
185 |
5b237745
|
Scott Ullrich
|
</td>
|
186 |
|
|
</tr>
|
187 |
7f5b4824
|
Scott Ullrich
|
<tr>
|
188 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
189 |
|
|
<td width="78%"><span class="vexpl"><span class="red"><strong>Warning:<br>
|
190 |
7f5b4824
|
Scott Ullrich
|
</strong></span>after you click "Save", you must
|
191 |
|
|
reboot your firewall for changes to take effect. You may also
|
192 |
|
|
have to do one or more of the following steps before you can
|
193 |
|
|
access your firewall again:
|
194 |
5b237745
|
Scott Ullrich
|
<ul>
|
195 |
|
|
<li>change the IP address of your computer</li>
|
196 |
|
|
<li>renew its DHCP lease</li>
|
197 |
|
|
<li>access the webGUI with the new IP address</li>
|
198 |
|
|
</ul>
|
199 |
|
|
</span></td>
|
200 |
|
|
</tr>
|
201 |
|
|
</table>
|
202 |
|
|
</form>
|
203 |
|
|
<?php include("fend.inc"); ?>
|
204 |
|
|
</body>
|
205 |
|
|
</html>
|