Project

General

Profile

Download (13.4 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_advanced_firewall.php
5
	part of pfSense
6
	Copyright (C) 2005-2007 Scott Ullrich
7

    
8
	Copyright (C) 2008 Shrew Soft Inc
9

    
10
	originally part of m0n0wall (http://m0n0.ch/wall)
11
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13

    
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16

    
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19

    
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23

    
24
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35

    
36
##|+PRIV
37
##|*IDENT=page-system-advanced-firewall
38
##|*NAME=System: Advanced: Firewall and NAT page
39
##|*DESCR=Allow access to the 'System: Advanced: Firewall and NAT' page.
40
##|*MATCH=system_advanced.php*
41
##|-PRIV
42

    
43

    
44
require("guiconfig.inc");
45

    
46
$pconfig['disablefilter'] = $config['system']['disablefilter'];
47
$pconfig['rfc959workaround'] = $config['system']['rfc959workaround'];
48
$pconfig['scrubnodf'] = $config['system']['scrubnodf'];
49
$pconfig['tcpidletimeout'] = $config['filter']['tcpidletimeout'];
50
$pconfig['optimization'] = $config['filter']['optimization'];
51
$pconfig['maximumstates'] = $config['system']['maximumstates'];
52
$pconfig['disablenatreflection'] = $config['system']['disablenatreflection'];
53
$pconfig['reflectiontimeout'] = $config['system']['reflectiontimeout'];
54
$pconfig['bypassstaticroutes'] = isset($config['filter']['bypassstaticroutes']);
55
$pconfig['disablescrub'] = isset($config['system']['disablescrub']);
56

    
57
if ($_POST) {
58

    
59
	unset($input_errors);
60
	$pconfig = $_POST;
61

    
62
	/* input validation */
63
	if ($_POST['maximumstates'] && !is_numericint($_POST['maximumstates'])) {
64
		$input_errors[] = "The Firewall Maximum States value must be an integer.";
65
	}
66
	if ($_POST['tcpidletimeout'] && !is_numericint($_POST['tcpidletimeout'])) {
67
		$input_errors[] = "The TCP idle timeout must be an integer.";
68
	}
69
	if ($_POST['reflectiontimeout'] && !is_numericint($_POST['reflectiontimeout'])) {
70
		$input_errors[] = "The Reflection timeout must be an integer.";
71
	}
72

    
73
    ob_flush();
74
    flush();
75

    
76
	if (!$input_errors) {
77

    
78
		if($_POST['disablefilter'] == "yes")
79
			$config['system']['disablefilter'] = "enabled";
80
		else
81
			unset($config['system']['disablefilter']);
82

    
83
		if($_POST['rfc959workaround'] == "yes")
84
			$config['system']['rfc959workaround'] = "enabled";
85
		else
86
			unset($config['system']['rfc959workaround']);
87

    
88
		if($_POST['scrubnodf'] == "yes")
89
			$config['system']['scrubnodf'] = "enabled";
90
		else
91
			unset($config['system']['scrubnodf']);
92

    
93
		$config['system']['optimization'] = $_POST['optimization'];
94
		$config['system']['maximumstates'] = $_POST['maximumstates'];
95

    
96
		if($_POST['disablenatreflection'] == "yes")
97
			$config['system']['disablenatreflection'] = $_POST['disablenatreflection'];
98
		else
99
			unset($config['system']['disablenatreflection']);
100
		
101
		$config['system']['reflectiontimeout'] = $_POST['reflectiontimeout'];
102

    
103
		if($_POST['bypassstaticroutes'] == "yes")
104
			$config['system']['bypassstaticroutes'] = $_POST['bypassstaticroutes'];
105
		else
106
			unset($config['system']['bypassstaticroutes']);
107

    
108
		if($_POST['disablescrub'] == "yes")
109
			$config['system']['disablescrub'] = $_POST['disablescrub'];
110
		else
111
			unset($config['system']['disablescrub']);
112

    
113
		write_config();
114

    
115
		$retval = 0;
116
		config_lock();
117
		$retval = filter_configure();
118
		if(stristr($retval, "error") <> true)
119
		    $savemsg = get_std_save_message($retval);
120
		else
121
		    $savemsg = $retval;
122
	}
123
}
124

    
125
$pgtitle = array("System","Advanced: Firewall and NAT");
126
include("head.inc");
127

    
128
?>
129

    
130
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
131
<?php include("fbegin.inc"); ?>
132

    
133
<script language="JavaScript">
134
<!--
135

    
136
var descs=new Array(5);
137
descs[0]="as the name says, it's the normal optimization algorithm";
138
descs[1]="used for high latency links, such as satellite links.  Expires idle connections later than default";
139
descs[2]="expires idle connections quicker. More efficient use of CPU and memory but can drop legitimate connections";
140
descs[3]="tries to avoid dropping any legitimate connections at the expense of increased memory usage and CPU utilization.";
141

    
142
function update_description(itemnum) {
143
        document.forms[0].info.value=descs[itemnum];
144

    
145
}
146

    
147
//-->
148
</script>
149

    
150
<?php
151
	if ($input_errors)
152
		print_input_errors($input_errors);
153
	if ($savemsg)
154
		print_info_box($savemsg);
155
?>
156
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
157
		<tr>
158
			<td>
159
				<span class="vexpl">
160
					<span class="red">
161
						<strong>Note:</strong>
162
					</span>
163
					the options on this page are intended for use by advanced users only.
164
					<br/>
165
				</span>
166
				<br/>
167
			</td>
168
		</tr>
169
		<tr>
170
			<td class="tabnavtbl">
171
				<ul id="tabnav">
172
				<?php
173
					$tab_array = array();
174
					$tab_array[] = array("Admin Access", false, "system_advanced_admin.php");
175
					$tab_array[] = array("Firewall / NAT", true, "system_advanced_firewall.php");
176
					$tab_array[] = array("Networking", false, "system_advanced_network.php");
177
					$tab_array[] = array("Miscellaneous", false, "system_advanced_misc.php");
178
					$tab_array[] = array("System Tunables", false, "system_advanced_sysctl.php");
179
					display_top_tabs($tab_array);
180
				?>
181
				</ul>
182
			</td>
183
		</tr>
184
		<tr>
185
			<td class="tabcont">
186
				<form action="system_advanced_firewall.php" method="post" name="iform" id="iform">
187
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
188
						<tr>
189
							<td colspan="2" valign="top" class="listtopic">Firewall Advanced</td>
190
						</tr>
191
<?php
192
/*
193
						<tr>
194
							<td width="22%" valign="top" class="vncell">Traffic shaper type</td>
195
							<td width="78%" class="vtable">
196
								<select name="shapertype" class="formselect">
197
									<option value="pfSense"<?php if($pconfig['shapertype'] == 'pfSense') echo " selected"; ?>><?= $g['product_name'] ?> (ALTQ)</option>
198
									<option value="m0n0"<?php if($pconfig['shapertype'] == 'm0n0') echo " selected"; ?>>M0n0wall (dummynet)</option>
199
								</select>
200
							</td>
201
						</tr>
202
*/
203
?>
204
						<tr>
205
							<td width="22%" valign="top" class="vncell">FTP server compatibility</td>
206
							<td width="78%" class="vtable">
207
								<input name="rfc959workaround" type="checkbox" id="rfc959workaround" value="yes" <?php if (isset($config['system']['rfc959workaround'])) echo "checked"; ?> />
208
								<strong>Allow data connections from the FTP command port</strong><br/>
209
								This allows for communication with ftp servers that violate
210
								RFC 959 by opening data connections from the command port (21).
211
								Thes should be opened on the data port(20). This option should
212
								not expose you to any extra risk as the firewall will still only
213
								allow connections on a port that ftp-proxy listens on.
214
							</td>
215
						</tr>
216
						<tr>
217
							<td width="22%" valign="top" class="vncell">IP Do-Not-Fragment compatibility</td>
218
							<td width="78%" class="vtable">
219
								<input name="scrubnodf" type="checkbox" id="scrubnodf" value="yes" <?php if (isset($config['system']['scrubnodf'])) echo "checked"; ?> />
220
								<strong>Clear invalid DF bits instead of dropping the packets</strong><br/>
221
								This allows for communications with hosts that generate fragmented
222
								packets with the don't fragment (DF) bit set. Linux NFS is known to
223
								do this. This will cause the filter to not drop such packets but
224
								instead clear the don't fragment bit. The filter will also randomize
225
								the IP identification field of outgoing packets with this option on,
226
								to compensate for operating systems that set the DF bit but set a
227
								zero IP identification header field.
228
							</td>
229
						</tr>
230
						<tr>
231
							<td width="22%" valign="top" class="vncell">Firewall Optimization Options</td>
232
							<td width="78%" class="vtable">
233
								<select onChange="update_description(this.selectedIndex);" name="optimization" id="optimization">
234
									<option value="normal"<?php if($config['system']['optimization']=="normal") echo " selected"; ?>>normal</option>
235
									<option value="high-latency"<?php if($config['system']['optimization']=="high-latency") echo " selected"; ?>>high-latency</option>
236
									<option value="aggressive"<?php if($config['system']['optimization']=="aggressive") echo " selected"; ?>>aggressive</option>
237
									<option value="conservative"<?php if($config['system']['optimization']=="conservative") echo " selected"; ?>>conservative</option>
238
								</select>
239
								<br/>
240
								<textarea cols="60" rows="1" id="info" name="info"style="padding:5px; border:1px dashed #990000; background-color: #ffffff; color: #000000; font-size: 8pt;"></textarea>
241
								<script language="javascript" type="text/javascript">
242
									update_description(document.forms[0].optimization.selectedIndex);
243
								</script>
244
								<br/>
245
								Select which type of state table optimization your would like to use
246
							</td>
247
						</tr>
248
						<tr>
249
							<td width="22%" valign="top" class="vncell">Disable Firewall</td>
250
							<td width="78%" class="vtable">
251
								<input name="disablefilter" type="checkbox" id="disablefilter" value="yes" <?php if (isset($config['system']['disablefilter'])) echo "checked"; ?> />
252
								<strong>Disable all packet filtering.</strong>
253
								<br/>
254
								<span class="vexpl">Note:  This converts <?= $g['product_name'] ?> into a routing only platform!<br>
255
			    	                Note:  This will turn off NAT!
256
								</span>
257
							</td>
258
						</tr>
259
						<tr>
260
							<td width="22%" valign="top" class="vncell">Disable Firewall Scrub</td>
261
							<td width="78%" class="vtable">
262
								<input name="disablescrub" type="checkbox" id="disablescrub" value="yes" <?php if (isset($config['system']['disablescrub'])) echo "checked"; ?> />
263
								<strong>Disables the PF scrubbing option which can sometimes interfere with NFS and PPTP traffic.</strong>
264
								<br/>
265
								Click <a href='http://www.openbsd.org/faq/pf/scrub.html' target='_new'>here</a> for more information.
266
							</td>
267
						</tr>
268
						<tr>
269
							<td width="22%" valign="top" class="vncell">Firewall Maximum States</td>
270
							<td width="78%" class="vtable">
271
								<input name="maximumstates" type="text" id="maximumstates" value="<?php echo $pconfig['maximumstates']; ?>" />
272
								<br/>
273
								<strong>Maximum number of connections to hold in the firewall state table.</strong>
274
								<br/>
275
								<span class="vexpl">Note:  Leave this blank for the default.  On your system the default size is: <?= pfsense_default_state_size() ?></span>
276
							</td>
277
						</tr>
278
						<tr>
279
							<td width="22%" valign="top" class="vncell">Static route filtering</td>
280
							<td width="78%" class="vtable">
281
								<input name="bypassstaticroutes" type="checkbox" id="bypassstaticroutes" value="yes" <?php if ($pconfig['bypassstaticroutes']) echo "checked"; ?> />
282
								<strong>Bypass firewall rules for traffic on the same interface</strong>
283
								<br/>
284
								This option only applies if you have defined one or more static routes. If it is enabled, traffic that enters and
285
				 				leaves through the same interface will not be checked by the firewall. This may be desirable in some situations where
286
								multiple subnets are connected to the same interface.
287
								<br/>
288
							</td>
289
						</tr>
290
						<tr>
291
							<td colspan="2" class="list" height="12">&nbsp;</td>
292
						</tr>
293

    
294
						<?php if($config['interfaces']['lan']): ?>
295
						<tr>
296
							<td colspan="2" valign="top" class="listtopic">Network Address Translation</td>
297
						</tr>		
298
						<tr>
299
							<td width="22%" valign="top" class="vncell">Disable NAT Reflection</td>
300
							<td width="78%" class="vtable">
301
								<input name="disablenatreflection" type="checkbox" id="disablenatreflection" value="yes" <?php if (isset($config['system']['disablenatreflection'])) echo "checked"; ?> />
302
								<strong>Disables the automatic creation of NAT redirect rules for access to your public IP addresses from within your internal networks.  Note: Reflection only works on port forward type items  and does not work for large ranges > 500 ports.</strong>
303
							</td>
304
						</tr>
305
						<tr>
306
							<td width="22%" valign="top" class="vncell">Reflection Timeout</td>
307
							<td width="78%" class="vtable">
308
								<input name="reflectiontimeout" id="reflectiontimeout" value="<?php echo $config['system']['reflectiontimeout']; ?>" />
309
								<strong>Enter value for Reflection timeout in seconds.</strong>
310
							</td>
311
						</tr>
312
						<tr>
313
							<td colspan="2" class="list" height="12">&nbsp;</td>
314
						</tr>
315
						<?php endif; ?>
316
						<tr>
317
							<td width="22%" valign="top">&nbsp;</td>
318
							<td width="78%"><input name="Submit" type="submit" class="formbtn" value="Save" /></td>
319
						</tr>
320
					</table>
321
				</form>
322
			</td>
323
		</tr>
324
	</table>
325

    
326
<?php include("fend.inc"); ?>
327
</body>
328
</html>
329

    
(166-166/211)