Project

General

Profile

Download (17.3 KB) Statistics
| Branch: | Tag: | Revision:
1 df81417f Matthew Grooms
<?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 1d333258 Scott Ullrich
/*
36
	pfSense_MODULE:	system
37
*/
38 df81417f Matthew Grooms
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 7a927e67 Scott Ullrich
require_once("functions.inc");
48
require_once("filter.inc");
49
require_once("shaper.inc");
50 df81417f Matthew Grooms
51
$pconfig['disablefilter'] = $config['system']['disablefilter'];
52
$pconfig['rfc959workaround'] = $config['system']['rfc959workaround'];
53
$pconfig['scrubnodf'] = $config['system']['scrubnodf'];
54 2867fa7b Ermal Luçi
$pconfig['scrubrnid'] = $config['system']['scrubrnid'];
55 df81417f Matthew Grooms
$pconfig['tcpidletimeout'] = $config['filter']['tcpidletimeout'];
56
$pconfig['optimization'] = $config['filter']['optimization'];
57
$pconfig['maximumstates'] = $config['system']['maximumstates'];
58 fb586a16 jim-p
$pconfig['maximumtableentries'] = $config['system']['maximumtableentries'];
59 df81417f Matthew Grooms
$pconfig['disablenatreflection'] = $config['system']['disablenatreflection'];
60 9fc22c6f Erik Fonnesbeck
if (!isset($config['system']['enablebinatreflection']))
61
	$pconfig['disablebinatreflection'] = "yes";
62
else
63
	$pconfig['disablebinatreflection'] = "";
64 bff94015 Erik Fonnesbeck
$pconfig['reflectiontimeout'] = $config['system']['reflectiontimeout'];
65 df81417f Matthew Grooms
$pconfig['bypassstaticroutes'] = isset($config['filter']['bypassstaticroutes']);
66
$pconfig['disablescrub'] = isset($config['system']['disablescrub']);
67 1beafceb Erik Fonnesbeck
$pconfig['tftpinterface'] = explode(",", $config['system']['tftpinterface']);
68 df81417f Matthew Grooms
69
if ($_POST) {
70
71
	unset($input_errors);
72
	$pconfig = $_POST;
73
74
	/* input validation */
75
	if ($_POST['maximumstates'] && !is_numericint($_POST['maximumstates'])) {
76 ca23c2f8 Renato Botelho
		$input_errors[] = gettext("The Firewall Maximum States value must be an integer.");
77 df81417f Matthew Grooms
	}
78 fb586a16 jim-p
	if ($_POST['maximumtableentries'] && !is_numericint($_POST['maximumtableentries'])) {
79
		$input_errors[] = gettext("The Firewall Maximum Table Entries value must be an integer.");
80
	}
81 df81417f Matthew Grooms
	if ($_POST['tcpidletimeout'] && !is_numericint($_POST['tcpidletimeout'])) {
82 ca23c2f8 Renato Botelho
		$input_errors[] = gettext("The TCP idle timeout must be an integer.");
83 df81417f Matthew Grooms
	}
84 bff94015 Erik Fonnesbeck
	if ($_POST['reflectiontimeout'] && !is_numericint($_POST['reflectiontimeout'])) {
85
		$input_errors[] = gettext("The Reflection timeout must be an integer.");
86
	}
87 df81417f Matthew Grooms
88
    ob_flush();
89
    flush();
90
91
	if (!$input_errors) {
92
93
		if($_POST['disablefilter'] == "yes")
94
			$config['system']['disablefilter'] = "enabled";
95
		else
96
			unset($config['system']['disablefilter']);
97
98
		if($_POST['rfc959workaround'] == "yes")
99
			$config['system']['rfc959workaround'] = "enabled";
100
		else
101
			unset($config['system']['rfc959workaround']);
102
103
		if($_POST['scrubnodf'] == "yes")
104
			$config['system']['scrubnodf'] = "enabled";
105
		else
106
			unset($config['system']['scrubnodf']);
107
108 2867fa7b Ermal Luçi
		if($_POST['scrubrnid'] == "yes")
109
                        $config['system']['scrubrnid'] = "enabled";
110
                else
111
                        unset($config['system']['scrubrnid']);
112
113 df81417f Matthew Grooms
		$config['system']['optimization'] = $_POST['optimization'];
114
		$config['system']['maximumstates'] = $_POST['maximumstates'];
115 fb586a16 jim-p
		$config['system']['maximumtableentries'] = $_POST['maximumtableentries'];
116 df81417f Matthew Grooms
117
		if($_POST['disablenatreflection'] == "yes")
118
			$config['system']['disablenatreflection'] = $_POST['disablenatreflection'];
119
		else
120
			unset($config['system']['disablenatreflection']);
121 9fc22c6f Erik Fonnesbeck
122
		if($_POST['disablebinatreflection'] == "yes")
123
			unset($config['system']['enablebinatreflection']);
124
		else
125
			$config['system']['enablebinatreflection'] = "yes";
126 df81417f Matthew Grooms
127 bff94015 Erik Fonnesbeck
		$config['system']['reflectiontimeout'] = $_POST['reflectiontimeout'];
128
129 df81417f Matthew Grooms
		if($_POST['bypassstaticroutes'] == "yes")
130 668c4990 Seth Mos
			$config['filter']['bypassstaticroutes'] = $_POST['bypassstaticroutes'];
131 df81417f Matthew Grooms
		else
132 668c4990 Seth Mos
			unset($config['filter']['bypassstaticroutes']);
133 df81417f Matthew Grooms
134
		if($_POST['disablescrub'] == "yes")
135
			$config['system']['disablescrub'] = $_POST['disablescrub'];
136
		else
137
			unset($config['system']['disablescrub']);
138
139 cfdce2ad Ermal
		if ($_POST['tftpinterface'])
140
			$config['system']['tftpinterface'] = implode(",", $_POST['tftpinterface']);
141
		else
142
			unset($config['system']['tftpinterface']);
143
	
144 df81417f Matthew Grooms
		write_config();
145
146 bd448e7f Ermal Lu?i
		/* 
147
		 * XXX: This is a kludge here but its the better place than on every filter reload.
148
		 * NOTE: This is only for setting the ipfw state limits. 
149
		 */
150
		if ($_POST['maximumstates'] && is_numeric($_POST['maximumstates']) && is_module_loaded("ipfw.ko"))
151
			filter_load_ipfw();
152
			
153 df81417f Matthew Grooms
		$retval = 0;
154
		$retval = filter_configure();
155
		if(stristr($retval, "error") <> true)
156
		    $savemsg = get_std_save_message($retval);
157
		else
158
		    $savemsg = $retval;
159
	}
160
}
161
162 ca23c2f8 Renato Botelho
$pgtitle = array(gettext("System"),gettext("Advanced: Firewall and NAT"));
163 df81417f Matthew Grooms
include("head.inc");
164
165
?>
166
167
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
168
<?php include("fbegin.inc"); ?>
169
170
<script language="JavaScript">
171
<!--
172
173
var descs=new Array(5);
174 ca23c2f8 Renato Botelho
descs[0]="<?=gettext("as the name says, it's the normal optimization algorithm");?>";
175
descs[1]="<?=gettext("used for high latency links, such as satellite links.  Expires idle connections later than default");?>";
176
descs[2]="<?=gettext("expires idle connections quicker. More efficient use of CPU and memory but can drop legitimate connections");?>";
177
descs[3]="<?=gettext("tries to avoid dropping any legitimate connections at the expense of increased memory usage and CPU utilization.");?>";
178 df81417f Matthew Grooms
179
function update_description(itemnum) {
180
        document.forms[0].info.value=descs[itemnum];
181
182
}
183
184
//-->
185
</script>
186
187
<?php
188
	if ($input_errors)
189
		print_input_errors($input_errors);
190
	if ($savemsg)
191
		print_info_box($savemsg);
192
?>
193 ab3c8553 Matthew Grooms
	<form action="system_advanced_firewall.php" method="post" name="iform" id="iform">
194
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
195
			<tr>
196
				<td class="tabnavtbl">
197
					<?php
198
						$tab_array = array();
199 ca23c2f8 Renato Botelho
						$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
200
						$tab_array[] = array(gettext("Firewall / NAT"), true, "system_advanced_firewall.php");
201
						$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
202
						$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
203
						$tab_array[] = array(gettext("System Tunables"), false, "system_advanced_sysctl.php");
204
						$tab_array[] = array(gettext("Notifications"), false, "system_advanced_notifications.php");
205 ab3c8553 Matthew Grooms
						display_top_tabs($tab_array);
206
					?>
207 df81417f Matthew Grooms
				</ul>
208 ab3c8553 Matthew Grooms
				</td>
209
			</tr>
210
			<tr>
211 2ff19bfd Matthew Grooms
				<td id="mainarea">
212
					<div class="tabcont">
213
						<span class="vexpl">
214
							<span class="red">
215 ea53e38f Renato Botelho
								<strong><?=gettext("NOTE:");?>&nbsp</strong>
216 2ff19bfd Matthew Grooms
							</span>
217 ca23c2f8 Renato Botelho
							<?=gettext("The options on this page are intended for use by advanced users only.");?>
218 2ff19bfd Matthew Grooms
							<br/>
219
						</span>
220
						<br/>
221
						<table width="100%" border="0" cellpadding="6" cellspacing="0">
222 ab3c8553 Matthew Grooms
							<tr>
223 ca23c2f8 Renato Botelho
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Firewall Advanced");?></td>
224 ab3c8553 Matthew Grooms
							</tr>
225
							<tr>
226 ca23c2f8 Renato Botelho
								<td width="22%" valign="top" class="vncell"><?=gettext("IP Do-Not-Fragment compatibility");?></td>
227 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
228
									<input name="scrubnodf" type="checkbox" id="scrubnodf" value="yes" <?php if (isset($config['system']['scrubnodf'])) echo "checked"; ?> />
229 ca23c2f8 Renato Botelho
									<strong><?=gettext("Clear invalid DF bits instead of dropping the packets");?></strong><br/>
230 f0d1af93 Carlos Eduardo Ramos
									<?=gettext("This allows for communications with hosts that generate fragmented " .
231
									"packets with the don't fragment (DF) bit set. Linux NFS is known to " .
232
									"do this. This will cause the filter to not drop such packets but " .
233
									"instead clear the don't fragment bit.");?>
234 2867fa7b Ermal Luçi
								</td>
235
							</tr>
236
							<tr>
237 ca23c2f8 Renato Botelho
								<td width="22%" valign="top" class="vncell"><?=gettext("IP Random id generation");?></td>
238 2867fa7b Ermal Luçi
								<td width="78%" class="vtable">
239
									<input name="scrubrnid" type="checkbox" id="scrubnodf" value="yes" <?php if (isset($config['system']['scrubrnid'])) echo "checked"; ?> />
240 ca23c2f8 Renato Botelho
									<strong><?=gettext("Insert a stronger id into IP header of packets passing through the filter.");?></strong><br/>
241 f0d1af93 Carlos Eduardo Ramos
									<?=gettext("Replaces the IP identification field of packets with random values to " .
242
									"compensate for operating systems that use predicatable values. " .
243
									"This option only applies to packets that are not fragmented after the " .
244
									"optional packet reassembly.");?>
245 ab3c8553 Matthew Grooms
								</td>
246
							</tr>
247
							<tr>
248 ca23c2f8 Renato Botelho
								<td width="22%" valign="top" class="vncell"><?=gettext("Firewall Optimization Options");?></td>
249 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
250
									<select onChange="update_description(this.selectedIndex);" name="optimization" id="optimization">
251 ca23c2f8 Renato Botelho
										<option value="normal"<?php if($config['system']['optimization']=="normal") echo " selected"; ?>><?=gettext("normal");?></option>
252
										<option value="high-latency"<?php if($config['system']['optimization']=="high-latency") echo " selected"; ?>><?=gettext("high-latency");?></option>
253
										<option value="aggressive"<?php if($config['system']['optimization']=="aggressive") echo " selected"; ?>><?=gettext("aggressive");?></option>
254
										<option value="conservative"<?php if($config['system']['optimization']=="conservative") echo " selected"; ?>><?=gettext("conservative");?></option>
255 ab3c8553 Matthew Grooms
									</select>
256
									<br/>
257 dc4f649e Scott Ullrich
									<textarea readonly="yes" cols="60" rows="2" id="info" name="info"style="padding:5px; border:1px dashed #990000; background-color: #ffffff; color: #000000; font-size: 8pt;"></textarea>
258 ab3c8553 Matthew Grooms
									<script language="javascript" type="text/javascript">
259
										update_description(document.forms[0].optimization.selectedIndex);
260
									</script>
261
									<br/>
262 ca23c2f8 Renato Botelho
									<?=gettext("Select the type of state table optimization to use");?>
263 ab3c8553 Matthew Grooms
								</td>
264
							</tr>
265
							<tr>
266 ca23c2f8 Renato Botelho
								<td width="22%" valign="top" class="vncell"><?=gettext("Disable Firewall");?></td>
267 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
268
									<input name="disablefilter" type="checkbox" id="disablefilter" value="yes" <?php if (isset($config['system']['disablefilter'])) echo "checked"; ?> />
269 ca23c2f8 Renato Botelho
									<strong><?=gettext("Disable all packet filtering.");?></strong>
270 ab3c8553 Matthew Grooms
									<br/>
271 ca23c2f8 Renato Botelho
									<span class="vexpl"><?php printf(gettext("Note:  This converts %s into a routing only platform!"), $g['product_name']);?><br>
272
										<?=gettext("Note:  This will turn off NAT!");?>
273 ab3c8553 Matthew Grooms
									</span>
274
								</td>
275
							</tr>
276
							<tr>
277 ca23c2f8 Renato Botelho
								<td width="22%" valign="top" class="vncell"><?=gettext("Disable Firewall Scrub");?></td>
278 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
279
									<input name="disablescrub" type="checkbox" id="disablescrub" value="yes" <?php if (isset($config['system']['disablescrub'])) echo "checked"; ?> />
280 ca23c2f8 Renato Botelho
									<strong><?=gettext("Disables the PF scrubbing option which can sometimes interfere with NFS and PPTP traffic.");?></strong>
281 ab3c8553 Matthew Grooms
									<br/>
282 ca23c2f8 Renato Botelho
									<?=gettext("Click")?> <a href='http://www.openbsd.org/faq/pf/scrub.html' target='_new'><?=gettext("here");?></a> <?=gettext("for more information.");?>
283 ab3c8553 Matthew Grooms
								</td>
284
							</tr>
285
							<tr>
286 ca23c2f8 Renato Botelho
								<td width="22%" valign="top" class="vncell"><?=gettext("Firewall Maximum States");?></td>
287 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
288
									<input name="maximumstates" type="text" id="maximumstates" value="<?php echo $pconfig['maximumstates']; ?>" />
289
									<br/>
290 ca23c2f8 Renato Botelho
									<strong><?=gettext("Maximum number of connections to hold in the firewall state table.");?></strong>
291 ab3c8553 Matthew Grooms
									<br/>
292 ea53e38f Renato Botelho
									<span class="vexpl"><?=gettext("Note:  Leave this blank for the default.  On your system the default size is:");?> <?= pfsense_default_state_size() ?></span>
293 ab3c8553 Matthew Grooms
								</td>
294
							</tr>
295 fb586a16 jim-p
							<tr>
296
								<td width="22%" valign="top" class="vncell"><?=gettext("Firewall Maximum Table Entries");?></td>
297
								<td width="78%" class="vtable">
298
									<input name="maximumtableentries" type="text" id="maximumtableentries" value="<?php echo $pconfig['maximumtableentries']; ?>" />
299
									<br/>
300
									<strong><?=gettext("Maximum number of table entries for systems such as aliases, sshlockout, snort, etc, combined.");?></strong>
301
									<br/>
302
									<span class="vexpl">
303
										<?=gettext("Note:  Leave this blank for the default.");?>
304
										<?php if (empty($pconfig['maximumtableentries'])): ?>
305 ea53e38f Renato Botelho
											<?= gettext("On your system the default size is:");?> <?= pfsense_default_table_entries_size(); ?>
306 fb586a16 jim-p
										<?php endif; ?>
307
									</span>
308
								</td>
309
							</tr>
310 ab3c8553 Matthew Grooms
							<tr>
311 ca23c2f8 Renato Botelho
								<td width="22%" valign="top" class="vncell"><?=gettext("Static route filtering");?></td>
312 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
313
									<input name="bypassstaticroutes" type="checkbox" id="bypassstaticroutes" value="yes" <?php if ($pconfig['bypassstaticroutes']) echo "checked"; ?> />
314 ca23c2f8 Renato Botelho
									<strong><?=gettext("Bypass firewall rules for traffic on the same interface");?></strong>
315 ab3c8553 Matthew Grooms
									<br/>
316 f0d1af93 Carlos Eduardo Ramos
									<?=gettext("This option only applies if you have defined one or more static routes. If it is enabled, traffic that enters and " .
317
					 				"leaves through the same interface will not be checked by the firewall. This may be desirable in some situations where " .
318
									"multiple subnets are connected to the same interface.");?>
319 ab3c8553 Matthew Grooms
									<br/>
320
								</td>
321
							</tr>
322
							<tr>
323
								<td colspan="2" class="list" height="12">&nbsp;</td>
324
							</tr>
325 f691243d Ermal
							<?php if(count($config['interfaces']) > 1): ?>
326 ab3c8553 Matthew Grooms
							<tr>
327 ca23c2f8 Renato Botelho
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Network Address Translation");?></td>
328 ab3c8553 Matthew Grooms
							</tr>		
329
							<tr>
330 129bc052 Erik Fonnesbeck
								<td width="22%" valign="top" class="vncell"><?=gettext("Disable NAT Reflection for port forwards");?></td>
331 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
332
									<input name="disablenatreflection" type="checkbox" id="disablenatreflection" value="yes" <?php if (isset($config['system']['disablenatreflection'])) echo "checked"; ?> />
333 bff94015 Erik Fonnesbeck
									<strong><?=gettext("Disables the automatic creation of additional NAT redirect rules for access to port forwards on your external IP addresses from within your internal networks.  Note: Reflection for port forward entries is skipped for ranges larger than 500 ports.");?></strong>
334
								</td>
335
							</tr>
336
							<tr>
337
								<td width="22%" valign="top" class="vncell"><?=gettext("Reflection Timeout");?></td>
338
								<td width="78%" class="vtable">
339
									<input name="reflectiontimeout" id="reflectiontimeout" value="<?php echo $config['system']['reflectiontimeout']; ?>" /><br/>
340 ed69be7a Erik Fonnesbeck
									<strong><?=gettext("Enter value for Reflection timeout in seconds.  Note: Only applies to Reflection on port forwards.");?></strong>
341 ab3c8553 Matthew Grooms
								</td>
342
							</tr>
343
							<tr>
344 129bc052 Erik Fonnesbeck
								<td width="22%" valign="top" class="vncell"><?=gettext("Disable NAT Reflection for 1:1 NAT");?></td>
345 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
346 9fc22c6f Erik Fonnesbeck
									<input name="disablebinatreflection" type="checkbox" id="disablebinatreflection" value="yes" <?php if (!isset($config['system']['enablebinatreflection'])) echo "checked"; ?> />
347 bff94015 Erik Fonnesbeck
									<strong><?=gettext("Disables the automatic creation of additional NAT 1:1 mappings for access to 1:1 mappings of your external IP addresses from within your internal networks.  Note: Reflection for 1:1 NAT might not fully work in certain complex routing scenarios.");?></strong>
348 ab3c8553 Matthew Grooms
								</td>
349
							</tr>
350 cfdce2ad Ermal
							<tr>
351 ca23c2f8 Renato Botelho
								<td width="22%" valign="top" class="vncell"><?=gettext("TFTP Proxy");?></td>
352 cfdce2ad Ermal
								<td width="78%" class="vtable">
353
									<select name="tftpinterface[]" multiple="true" class="formselect" size="3">
354
<?php
355 ca23c2f8 Renato Botelho
										$ifdescs = get_configured_interface_with_descr();
356
										foreach ($ifdescs as $ifent => $ifdesc):
357 cfdce2ad Ermal
?>
358 1beafceb Erik Fonnesbeck
											<option value="<?=$ifent;?>" <?php if (in_array($ifent, $pconfig['tftpinterface'])) echo "selected"; ?>><?=gettext($ifdesc);?></option>
359 ca23c2f8 Renato Botelho
<?php									endforeach; ?>
360
									</select>
361 c3c2fd20 Erik Fonnesbeck
									<strong><?=gettext("Choose the interfaces where you want TFTP proxy helper to be enabled.");?></strong>
362 cfdce2ad Ermal
								</td>
363
							</tr>
364 ab3c8553 Matthew Grooms
							<tr>
365
								<td colspan="2" class="list" height="12">&nbsp;</td>
366
							</tr>
367
							<?php endif; ?>
368
							<tr>
369
								<td width="22%" valign="top">&nbsp;</td>
370 cf9331b3 Renato Botelho
								<td width="78%"><input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /></td>
371 ab3c8553 Matthew Grooms
							</tr>
372
						</table>
373
					</td>
374
				</tr>
375
			</div>
376
		</table>
377
	</form>
378 df81417f Matthew Grooms
379
<?php include("fend.inc"); ?>
380
</body>
381
</html>