Project

General

Profile

Download (13.3 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
	pfSense_MODULE:	system
37
*/
38

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

    
46
require("guiconfig.inc");
47

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

    
60
if ($_POST) {
61

    
62
	unset($input_errors);
63
	$pconfig = $_POST;
64

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

    
76
    ob_flush();
77
    flush();
78

    
79
	if (!$input_errors) {
80

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

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

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

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

    
101
		$config['system']['optimization'] = $_POST['optimization'];
102
		$config['system']['maximumstates'] = $_POST['maximumstates'];
103

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

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

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

    
121
		write_config();
122

    
123
		/* 
124
		 * XXX: This is a kludge here but its the better place than on every filter reload.
125
		 * NOTE: This is only for setting the ipfw state limits. 
126
		 */
127
		if ($_POST['maximumstates'] && is_numeric($_POST['maximumstates']) && is_module_loaded("ipfw.ko"))
128
			filter_load_ipfw();
129
			
130
		$retval = 0;
131
		$retval = filter_configure();
132
		if(stristr($retval, "error") <> true)
133
		    $savemsg = get_std_save_message($retval);
134
		else
135
		    $savemsg = $retval;
136
	}
137
}
138

    
139
$pgtitle = array("System","Advanced: Firewall and NAT");
140
include("head.inc");
141

    
142
?>
143

    
144
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
145
<?php include("fbegin.inc"); ?>
146

    
147
<script language="JavaScript">
148
<!--
149

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

    
156
function update_description(itemnum) {
157
        document.forms[0].info.value=descs[itemnum];
158

    
159
}
160

    
161
//-->
162
</script>
163

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

    
320
<?php include("fend.inc"); ?>
321
</body>
322
</html>
323

    
(170-170/217)