Project

General

Profile

Download (15.1 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
require_once("functions.inc");
48
require_once("filter.inc");
49
require_once("shaper.inc");
50

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

    
64
if ($_POST) {
65

    
66
	unset($input_errors);
67
	$pconfig = $_POST;
68

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

    
80
    ob_flush();
81
    flush();
82

    
83
	if (!$input_errors) {
84

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

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

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

    
100
		if($_POST['scrubrnid'] == "yes")
101
                        $config['system']['scrubrnid'] = "enabled";
102
                else
103
                        unset($config['system']['scrubrnid']);
104

    
105
		$config['system']['optimization'] = $_POST['optimization'];
106
		$config['system']['maximumstates'] = $_POST['maximumstates'];
107

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

    
115
		if($_POST['bypassstaticroutes'] == "yes")
116
			$config['filter']['bypassstaticroutes'] = $_POST['bypassstaticroutes'];
117
		else
118
			unset($config['filter']['bypassstaticroutes']);
119

    
120
		if($_POST['disablescrub'] == "yes")
121
			$config['system']['disablescrub'] = $_POST['disablescrub'];
122
		else
123
			unset($config['system']['disablescrub']);
124

    
125
		if ($_POST['tftpinterface'])
126
			$config['system']['tftpinterface'] = implode(",", $_POST['tftpinterface']);
127
		else
128
			unset($config['system']['tftpinterface']);
129
	
130
		write_config();
131

    
132
		/* 
133
		 * XXX: This is a kludge here but its the better place than on every filter reload.
134
		 * NOTE: This is only for setting the ipfw state limits. 
135
		 */
136
		if ($_POST['maximumstates'] && is_numeric($_POST['maximumstates']) && is_module_loaded("ipfw.ko"))
137
			filter_load_ipfw();
138
			
139
		$retval = 0;
140
		$retval = filter_configure();
141
		if(stristr($retval, "error") <> true)
142
		    $savemsg = get_std_save_message($retval);
143
		else
144
		    $savemsg = $retval;
145
	}
146
}
147

    
148
$pgtitle = array(gettext("System"),gettext("Advanced: Firewall and NAT"));
149
include("head.inc");
150

    
151
?>
152

    
153
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
154
<?php include("fbegin.inc"); ?>
155

    
156
<script language="JavaScript">
157
<!--
158

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

    
165
function update_description(itemnum) {
166
        document.forms[0].info.value=descs[itemnum];
167

    
168
}
169

    
170
//-->
171
</script>
172

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

    
343
<?php include("fend.inc"); ?>
344
</body>
345
</html>
346

    
(169-169/216)