Project

General

Profile

Download (9.41 KB) Statistics
| Branch: | Tag: | Revision:
1 7f5b4824 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
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 d9a31e93 Scott Ullrich
$optcfg = &$config['interfaces']['lan'];
36
37 e95c754f Bill Marquette
$pconfig['ipaddr'] = $lancfg['ipaddr'];
38
$pconfig['subnet'] = $lancfg['subnet'];
39 05aa1128 Scott Ullrich
$pconfig['bridge'] = $lancfg['bridge'];
40 03b92764 Scott Ullrich
41 c1ec2c2f Scott Ullrich
$pconfig['disableftpproxy'] = isset($lancfg['disableftpproxy']);
42
43 5b237745 Scott Ullrich
/* Wireless interface? */
44 b7f01f59 Bill Marquette
if (isset($lancfg['wireless'])) {
45 5b237745 Scott Ullrich
	require("interfaces_wlan.inc");
46
	wireless_config_init();
47
}
48
49
if ($_POST) {
50
51 6d6d0f14 Scott Ullrich
	if ($_POST['bridge']) {
52
		/* double bridging? */
53
		for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
54
			if ($i != $index) {
55
				if ($config['interfaces']['opt' . $i]['bridge'] == $_POST['bridge']) {
56 4ab4e4ef Scott Ullrich
					//$input_errors[] = "Optional interface {$i} " .
57
					//	"({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
58
					//	"the specified interface.";
59 6d6d0f14 Scott Ullrich
				} else if ($config['interfaces']['opt' . $i]['bridge'] == "opt{$index}") {
60 4ab4e4ef Scott Ullrich
					//$input_errors[] = "Optional interface {$i} " .
61
					//	"({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
62
					//	"this interface.";
63 6d6d0f14 Scott Ullrich
				}
64
			}
65 5b237745 Scott Ullrich
		}
66 6d6d0f14 Scott Ullrich
		if ($config['interfaces'][$_POST['bridge']]['bridge']) {
67 19c0f3b3 Scott Ullrich
			//$input_errors[] = "The specified interface is already bridged to " .
68
			//	"another interface.";
69 52442f57 Bill Marquette
		}
70 6d6d0f14 Scott Ullrich
		/* captive portal on? */
71
		if (isset($config['captiveportal']['enable'])) {
72 19c0f3b3 Scott Ullrich
			//$input_errors[] = "Interfaces cannot be bridged while the captive portal is enabled.";
73 001fdeea Scott Ullrich
		}
74 75211081 Scott Ullrich
	}
75
76
	unset($input_errors);
77
	$pconfig = $_POST;
78
	$changedesc = "LAN Interface: ";
79
80
	/* input validation */
81 623247f7 Scott Ullrich
	$reqdfields = explode(" ", "ipaddr subnet");
82
	$reqdfieldsn = explode(",", "IP address,Subnet bit count");
83
	
84
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
85
86 75211081 Scott Ullrich
	if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) {
87
		$input_errors[] = "A valid IP address must be specified.";
88
	}
89
	if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
90
		$input_errors[] = "A valid subnet bit count must be specified.";
91
	}
92
93
	/* Wireless interface? */
94
	if (isset($lancfg['wireless'])) {
95
		$wi_input_errors = wireless_config_post();
96
		if ($wi_input_errors) {
97
			$input_errors = array_merge($input_errors, $wi_input_errors);
98 6d6d0f14 Scott Ullrich
		}
99 75211081 Scott Ullrich
	}
100
101
	if (!$input_errors) {
102 8f33c905 Scott Ullrich
		
103 c1ec2c2f Scott Ullrich
		unset($lancfg['disableftpproxy']);
104
		
105
		/* per interface pftpx helper */
106
		if($_POST['disableftpproxy'] == "yes") {
107
			$lancfg['disableftpproxy'] = true;
108
			system_start_ftp_helpers();
109
		} else {			
110
			system_start_ftp_helpers();
111
		}			
112
		
113 9a6757a1 Scott Ullrich
		$bridge = discover_bridge($lancfg['if'], filter_translate_type_to_real_interface($lancfg['bridge']));
114 0d429e43 Scott Ullrich
		if($bridge <> "-1") {
115 1665e79c Scott Ullrich
			destroy_bridge($bridge);
116 91e8aab2 Scott Ullrich
		}
117 1665e79c Scott Ullrich
118 8f33c905 Scott Ullrich
		$lancfg['bridge'] = $_POST['bridge'];
119
		
120 75211081 Scott Ullrich
		if (($lancfg['ipaddr'] != $_POST['ipaddr']) || ($lancfg['subnet'] != $_POST['subnet'])) {
121
			update_if_changed("IP Address", &$lancfg['ipaddr'], $_POST['ipaddr']);
122
			update_if_changed("subnet", &$lancfg['subnet'], $_POST['subnet']);
123 6d6d0f14 Scott Ullrich
		}
124 75211081 Scott Ullrich
125
		write_config($changedesc);
126
127 03e6d007 Scott Ullrich
		touch($d_landirty_path);
128
129 1df27a05 Scott Ullrich
		/* restart snmp so that it binds to correct address */
130
		services_snmpd_configure();
131
132 f88a634b Scott Ullrich
		if ($_POST['apply'] <> "") {
133 b1659603 Scott Ullrich
			
134 f88a634b Scott Ullrich
			unlink($d_landirty_path);
135 c597d50f Scott Ullrich
			
136 5cc42c8b Scott Ullrich
			$savemsg = "The changes have been applied.  You may need to correct your web browser's IP address.";
137 b1659603 Scott Ullrich
			
138 03e6d007 Scott Ullrich
		}
139 5b237745 Scott Ullrich
	}
140
}
141 222b5299 Scott Ullrich
142 d88c6a9f Scott Ullrich
$pgtitle = array("Interfaces","LAN");
143 7f43ca88 Scott Ullrich
include("head.inc");
144
145
?>
146 b9e255dd Bill Marquette
147 5b237745 Scott Ullrich
<script language="JavaScript">
148
<!--
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
<?php if ($input_errors) print_input_errors($input_errors); ?>
164 03e6d007 Scott Ullrich
<?php if (file_exists($d_landirty_path)): ?><p>
165 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>
166 03e6d007 Scott Ullrich
<?php endif; ?>
167 bf158f5c Scott Ullrich
<?php if ($savemsg) print_info_box_np($savemsg); ?>
168 5b237745 Scott Ullrich
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
169 5b80d869 Scott Ullrich
		<tr>
170
                  <td colspan="2" valign="top" class="listtopic">IP configuration</td>
171
		</tr>	      
172 6d6d0f14 Scott Ullrich
		<tr>
173
                  <td width="22%" valign="top" class="vncellreq">Bridge with</td>
174
                  <td width="78%" class="vtable">
175 b5c78501 Seth Mos
			<select name="bridge" class="formselect" id="bridge" onChange="enable_change(false)">
176 6d6d0f14 Scott Ullrich
				  	<option <?php if (!$pconfig['bridge']) echo "selected";?> value="">none</option>
177 f107446c Scott Ullrich
                      <?php $opts = array('wan' => "WAN");
178 6d6d0f14 Scott Ullrich
					  	for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
179
							if ($i != $index)
180
								$opts['opt' . $i] = "Optional " . $i . " (" .
181
									$config['interfaces']['opt' . $i]['descr'] . ")";
182
						}
183
					foreach ($opts as $opt => $optname): ?>
184
                      <option <?php if ($opt == $pconfig['bridge']) echo "selected";?> value="<?=htmlspecialchars($opt);?>">
185
                      <?=htmlspecialchars($optname);?>
186
                      </option>
187
                      <?php endforeach; ?>
188
                    </select> </td>
189
		</tr>	      
190 7f5b4824 Scott Ullrich
                <tr>
191 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">IP address</td>
192 7f5b4824 Scott Ullrich
                  <td width="78%" class="vtable">
193 b5c78501 Seth Mos
                    <input name="ipaddr" type="text" class="formfld unknown" id="hostname" size="20" value="<?=htmlspecialchars($pconfig['ipaddr']);?>">
194 7f5b4824 Scott Ullrich
                    /
195 b5c78501 Seth Mos
                    <select name="subnet" class="formselect" id="subnet">
196 21ab1cde Scott Ullrich
					<?php
197
					for ($i = 32; $i > 0; $i--) {
198
						if($i <> 31) {
199
							echo "<option value=\"{$i}\" ";
200
							if ($i == $pconfig['subnet']) echo "selected";
201
							echo ">" . $i . "</option>";
202
						}
203
					}
204
					?>
205 5b237745 Scott Ullrich
                    </select></td>
206
                </tr>
207 3c393400 Scott Ullrich
                <tr>
208
                  <td colspan="2" valign="top" height="16"></td>
209
                </tr>
210
                <tr>
211
                  <td colspan="2" valign="top" class="listtopic">FTP Helper</td>
212
                </tr>		
213
		<tr>
214
			<td width="22%" valign="top" class="vncell">FTP Helper</td>
215
			<td width="78%" class="vtable">
216 0135299b Scott Ullrich
				<input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if ($pconfig['disableftpproxy']) echo "checked"; ?> onclick="enable_change(false)" />
217 3c393400 Scott Ullrich
				<strong>Disable the userland FTP-Proxy application</strong>
218
				<br />
219
			</td>
220
		</tr>			
221 5b237745 Scott Ullrich
				<?php /* Wireless interface? */
222 b7f01f59 Bill Marquette
				if (isset($lancfg['wireless']))
223 5b237745 Scott Ullrich
					wireless_config_print();
224
				?>
225 73c38fa2 Scott Ullrich
226
227 da56c4d7 Scott Ullrich
                <tr>
228
                  <td colspan="2" valign="top" height="16"></td>
229
                </tr>
230 7f5b4824 Scott Ullrich
                <tr>
231 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
232 7f5b4824 Scott Ullrich
                  <td width="78%">
233
                    <input name="Submit" type="submit" class="formbtn" value="Save">
234 5b237745 Scott Ullrich
                  </td>
235
                </tr>
236 7f5b4824 Scott Ullrich
                <tr>
237 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
238
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Warning:<br>
239 0390c50a Bill Marquette
                    </strong></span>after you click &quot;Save&quot;, you will need
240 c55a8ab9 Holger Bauer
                    to do one or more of the following steps before you can
241 7f5b4824 Scott Ullrich
                    access your firewall again:
242 5b237745 Scott Ullrich
                    <ul>
243
                      <li>change the IP address of your computer</li>
244
                      <li>renew its DHCP lease</li>
245 709cc6e0 Bill Marquette
                      <li>access the webConfigurator with the new IP address</li>
246 f0dcff6f Scott Ullrich
		      <li>be sure to add <a href="firewall_rules.php">firewall rules</a> to permit traffic through the interface.</li>
247
		      <li>You also need firewall rules for an interface in bridged mode as the firewall acts as a filtering bridge.</li>
248 5b237745 Scott Ullrich
                    </ul>
249
                    </span></td>
250
                </tr>
251
              </table>
252
</form>
253
<?php include("fend.inc"); ?>
254
</body>
255
</html>
256 b5933544 Scott Ullrich
257
<?php
258
259 f88a634b Scott Ullrich
if ($_POST['apply'] <> "") {
260 b5933544 Scott Ullrich
261 2e70a096 Scott Ullrich
	ob_flush();
262
	flush();
263
	
264 789e0b9d Scott Ullrich
	interfaces_lan_configure();
265 e4e8c30f Scott Ullrich
	
266 610b1136 Scott Ullrich
	reset_carp();
267 fd4ce0e0 Scott Ullrich
	
268 e4e8c30f Scott Ullrich
	/* sync filter configuration */
269
	filter_configure();
270 8e11b23f Scott Ullrich
271
	/* set up static routes */
272
	system_routing_configure();
273 e4e8c30f Scott Ullrich
	
274 ed1320e7 Scott Ullrich
	if(file_exists($d_landirty_path))
275 c597d50f Scott Ullrich
		unlink($d_landirty_path);
276 b5933544 Scott Ullrich
	
277
}
278
279 b5c78501 Seth Mos
?>