Project

General

Profile

Download (13 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['scrubrnid'] = $config['system']['scrubrnid'];
50
$pconfig['tcpidletimeout'] = $config['filter']['tcpidletimeout'];
51
$pconfig['optimization'] = $config['filter']['optimization'];
52
$pconfig['maximumstates'] = $config['system']['maximumstates'];
53
$pconfig['disablenatreflection'] = $config['system']['disablenatreflection'];
54
$pconfig['reflectiontimeout'] = $config['system']['reflectiontimeout'];
55
$pconfig['bypassstaticroutes'] = isset($config['filter']['bypassstaticroutes']);
56
$pconfig['disablescrub'] = isset($config['system']['disablescrub']);
57

    
58
if ($_POST) {
59

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

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

    
74
    ob_flush();
75
    flush();
76

    
77
	if (!$input_errors) {
78

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

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

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

    
94
		if($_POST['scrubrnid'] == "yes")
95
                        $config['system']['scrubrnid'] = "enabled";
96
                else
97
                        unset($config['system']['scrubrnid']);
98

    
99
		$config['system']['optimization'] = $_POST['optimization'];
100
		$config['system']['maximumstates'] = $_POST['maximumstates'];
101

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

    
109
		if($_POST['bypassstaticroutes'] == "yes")
110
			$config['filter']['bypassstaticroutes'] = $_POST['bypassstaticroutes'];
111
		else
112
			unset($config['filter']['bypassstaticroutes']);
113

    
114
		if($_POST['disablescrub'] == "yes")
115
			$config['system']['disablescrub'] = $_POST['disablescrub'];
116
		else
117
			unset($config['system']['disablescrub']);
118

    
119
		write_config();
120

    
121
		$retval = 0;
122
		config_lock();
123
		$retval = filter_configure();
124
		if(stristr($retval, "error") <> true)
125
		    $savemsg = get_std_save_message($retval);
126
		else
127
		    $savemsg = $retval;
128
	}
129
}
130

    
131
$pgtitle = array("System","Advanced: Firewall and NAT");
132
include("head.inc");
133

    
134
?>
135

    
136
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
137
<?php include("fbegin.inc"); ?>
138

    
139
<script language="JavaScript">
140
<!--
141

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

    
148
function update_description(itemnum) {
149
        document.forms[0].info.value=descs[itemnum];
150

    
151
}
152

    
153
//-->
154
</script>
155

    
156
<?php
157
	if ($input_errors)
158
		print_input_errors($input_errors);
159
	if ($savemsg)
160
		print_info_box($savemsg);
161
?>
162
	<form action="system_advanced_firewall.php" method="post" name="iform" id="iform">
163
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
164
			<tr>
165
				<td class="tabnavtbl">
166
					<?php
167
						$tab_array = array();
168
						$tab_array[] = array("Admin Access", false, "system_advanced_admin.php");
169
						$tab_array[] = array("Firewall / NAT", true, "system_advanced_firewall.php");
170
						$tab_array[] = array("Networking", false, "system_advanced_network.php");
171
						$tab_array[] = array("Miscellaneous", false, "system_advanced_misc.php");
172
						$tab_array[] = array("System Tunables", false, "system_advanced_sysctl.php");
173
						display_top_tabs($tab_array);
174
					?>
175
				</ul>
176
				</td>
177
			</tr>
178
			<tr>
179
				<td id="mainarea">
180
					<div class="tabcont">
181
						<span class="vexpl">
182
							<span class="red">
183
								<strong>NOTE:&nbsp</strong>
184
							</span>
185
							The options on this page are intended for use by advanced users only.
186
							<br/>
187
						</span>
188
						<br/>
189
						<table width="100%" border="0" cellpadding="6" cellspacing="0">
190
							<tr>
191
								<td colspan="2" valign="top" class="listtopic">Firewall Advanced</td>
192
							</tr>
193
							<tr>
194
								<td width="22%" valign="top" class="vncell">IP Do-Not-Fragment compatibility</td>
195
								<td width="78%" class="vtable">
196
									<input name="scrubnodf" type="checkbox" id="scrubnodf" value="yes" <?php if (isset($config['system']['scrubnodf'])) echo "checked"; ?> />
197
									<strong>Clear invalid DF bits instead of dropping the packets</strong><br/>
198
									This allows for communications with hosts that generate fragmented
199
									packets with the don't fragment (DF) bit set. Linux NFS is known to
200
									do this. This will cause the filter to not drop such packets but
201
									instead clear the don't fragment bit. 
202
								</td>
203
							</tr>
204
							<tr>
205
								<td width="22%" valign="top" class="vncell">IP Random id generation</td>
206
								<td width="78%" class="vtable">
207
									<input name="scrubrnid" type="checkbox" id="scrubnodf" value="yes" <?php if (isset($config['system']['scrubrnid'])) echo "checked"; ?> />
208
									<strong>Insert a stronger id into IP header of packets passing through the filter.</strong><br/>
209
									Replaces the IP identification field of packets with random values to
210
									compensate for operating systems that use predicatable values.
211
									This option only applies to packets that are not fragmented after the
212
									optional packet reassembly.
213
								</td>
214
							</tr>
215
							<tr>
216
								<td width="22%" valign="top" class="vncell">Firewall Optimization Options</td>
217
								<td width="78%" class="vtable">
218
									<select onChange="update_description(this.selectedIndex);" name="optimization" id="optimization">
219
										<option value="normal"<?php if($config['system']['optimization']=="normal") echo " selected"; ?>>normal</option>
220
										<option value="high-latency"<?php if($config['system']['optimization']=="high-latency") echo " selected"; ?>>high-latency</option>
221
										<option value="aggressive"<?php if($config['system']['optimization']=="aggressive") echo " selected"; ?>>aggressive</option>
222
										<option value="conservative"<?php if($config['system']['optimization']=="conservative") echo " selected"; ?>>conservative</option>
223
									</select>
224
									<br/>
225
									<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>
226
									<script language="javascript" type="text/javascript">
227
										update_description(document.forms[0].optimization.selectedIndex);
228
									</script>
229
									<br/>
230
									Select which type of state table optimization your would like to use
231
								</td>
232
							</tr>
233
							<tr>
234
								<td width="22%" valign="top" class="vncell">Disable Firewall</td>
235
								<td width="78%" class="vtable">
236
									<input name="disablefilter" type="checkbox" id="disablefilter" value="yes" <?php if (isset($config['system']['disablefilter'])) echo "checked"; ?> />
237
									<strong>Disable all packet filtering.</strong>
238
									<br/>
239
									<span class="vexpl">Note:  This converts <?= $g['product_name'] ?> into a routing only platform!<br>
240
				    	                Note:  This will turn off NAT!
241
									</span>
242
								</td>
243
							</tr>
244
							<tr>
245
								<td width="22%" valign="top" class="vncell">Disable Firewall Scrub</td>
246
								<td width="78%" class="vtable">
247
									<input name="disablescrub" type="checkbox" id="disablescrub" value="yes" <?php if (isset($config['system']['disablescrub'])) echo "checked"; ?> />
248
									<strong>Disables the PF scrubbing option which can sometimes interfere with NFS and PPTP traffic.</strong>
249
									<br/>
250
									Click <a href='http://www.openbsd.org/faq/pf/scrub.html' target='_new'>here</a> for more information.
251
								</td>
252
							</tr>
253
							<tr>
254
								<td width="22%" valign="top" class="vncell">Firewall Maximum States</td>
255
								<td width="78%" class="vtable">
256
									<input name="maximumstates" type="text" id="maximumstates" value="<?php echo $pconfig['maximumstates']; ?>" />
257
									<br/>
258
									<strong>Maximum number of connections to hold in the firewall state table.</strong>
259
									<br/>
260
									<span class="vexpl">Note:  Leave this blank for the default.  On your system the default size is: <?= pfsense_default_state_size() ?></span>
261
								</td>
262
							</tr>
263
							<tr>
264
								<td width="22%" valign="top" class="vncell">Static route filtering</td>
265
								<td width="78%" class="vtable">
266
									<input name="bypassstaticroutes" type="checkbox" id="bypassstaticroutes" value="yes" <?php if ($pconfig['bypassstaticroutes']) echo "checked"; ?> />
267
									<strong>Bypass firewall rules for traffic on the same interface</strong>
268
									<br/>
269
									This option only applies if you have defined one or more static routes. If it is enabled, traffic that enters and
270
					 				leaves through the same interface will not be checked by the firewall. This may be desirable in some situations where
271
									multiple subnets are connected to the same interface.
272
									<br/>
273
								</td>
274
							</tr>
275
							<tr>
276
								<td colspan="2" class="list" height="12">&nbsp;</td>
277
							</tr>
278
	
279
							<?php if($config['interfaces']['lan']): ?>
280
							<tr>
281
								<td colspan="2" valign="top" class="listtopic">Network Address Translation</td>
282
							</tr>		
283
							<tr>
284
								<td width="22%" valign="top" class="vncell">Disable NAT Reflection</td>
285
								<td width="78%" class="vtable">
286
									<input name="disablenatreflection" type="checkbox" id="disablenatreflection" value="yes" <?php if (isset($config['system']['disablenatreflection'])) echo "checked"; ?> />
287
									<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>
288
								</td>
289
							</tr>
290
							<tr>
291
								<td width="22%" valign="top" class="vncell">Reflection Timeout</td>
292
								<td width="78%" class="vtable">
293
									<input name="reflectiontimeout" id="reflectiontimeout" value="<?php echo $config['system']['reflectiontimeout']; ?>" /><br/>
294
									<strong>Enter value for Reflection timeout in seconds.</strong>
295
								</td>
296
							</tr>
297
							<tr>
298
								<td colspan="2" class="list" height="12">&nbsp;</td>
299
							</tr>
300
							<?php endif; ?>
301
							<tr>
302
								<td width="22%" valign="top">&nbsp;</td>
303
								<td width="78%"><input name="Submit" type="submit" class="formbtn" value="Save" /></td>
304
							</tr>
305
						</table>
306
					</td>
307
				</tr>
308
			</div>
309
		</table>
310
	</form>
311

    
312
<?php include("fend.inc"); ?>
313
</body>
314
</html>
315

    
(157-157/203)