Project

General

Profile

Download (19.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['maximumtableentries'] = $config['system']['maximumtableentries'];
59
$pconfig['disablereplyto'] = isset($config['system']['disablereplyto']);
60
$pconfig['disablenatreflection'] = $config['system']['disablenatreflection'];
61
if (!isset($config['system']['enablebinatreflection']))
62
	$pconfig['disablebinatreflection'] = "yes";
63
else
64
	$pconfig['disablebinatreflection'] = "";
65
$pconfig['reflectiontimeout'] = $config['system']['reflectiontimeout'];
66
$pconfig['bypassstaticroutes'] = isset($config['filter']['bypassstaticroutes']);
67
$pconfig['disablescrub'] = isset($config['system']['disablescrub']);
68
$pconfig['tftpinterface'] = explode(",", $config['system']['tftpinterface']);
69

    
70
if ($_POST) {
71

    
72
	unset($input_errors);
73
	$pconfig = $_POST;
74

    
75
	/* input validation */
76
	if ($_POST['maximumstates'] && !is_numericint($_POST['maximumstates'])) {
77
		$input_errors[] = gettext("The Firewall Maximum States value must be an integer.");
78
	}
79
	if ($_POST['maximumtableentries'] && !is_numericint($_POST['maximumtableentries'])) {
80
		$input_errors[] = gettext("The Firewall Maximum Table Entries value must be an integer.");
81
	}
82
	if ($_POST['tcpidletimeout'] && !is_numericint($_POST['tcpidletimeout'])) {
83
		$input_errors[] = gettext("The TCP idle timeout must be an integer.");
84
	}
85
	if ($_POST['reflectiontimeout'] && !is_numericint($_POST['reflectiontimeout'])) {
86
		$input_errors[] = gettext("The Reflection timeout must be an integer.");
87
	}
88

    
89
    ob_flush();
90
    flush();
91

    
92
	if (!$input_errors) {
93

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

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

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

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

    
114
		$config['system']['optimization'] = $_POST['optimization'];
115
		$config['system']['maximumstates'] = $_POST['maximumstates'];
116
		$config['system']['maximumtableentries'] = $_POST['maximumtableentries'];
117

    
118
		if($_POST['disablenatreflection'] == "yes")
119
			$config['system']['disablenatreflection'] = $_POST['disablenatreflection'];
120
		else
121
			unset($config['system']['disablenatreflection']);
122

    
123
		if($_POST['disablebinatreflection'] == "yes")
124
			unset($config['system']['enablebinatreflection']);
125
		else
126
			$config['system']['enablebinatreflection'] = "yes";
127

    
128
		if($_POST['disablereplyto'] == "yes")
129
                        $config['system']['disablereplyto'] = $_POST['disablereplyto'];
130
                else
131
                        unset($config['system']['disablereplyto']);
132

    
133
		if($_POST['enablenatreflectionhelper'] == "yes")
134
			$config['system']['enablenatreflectionhelper'] = "yes";
135
		else
136
			unset($config['system']['enablenatreflectionhelper']);
137

    
138
		$config['system']['reflectiontimeout'] = $_POST['reflectiontimeout'];
139

    
140
		if($_POST['bypassstaticroutes'] == "yes")
141
			$config['filter']['bypassstaticroutes'] = $_POST['bypassstaticroutes'];
142
		else
143
			unset($config['filter']['bypassstaticroutes']);
144

    
145
		if($_POST['disablescrub'] == "yes")
146
			$config['system']['disablescrub'] = $_POST['disablescrub'];
147
		else
148
			unset($config['system']['disablescrub']);
149

    
150
		if ($_POST['tftpinterface'])
151
			$config['system']['tftpinterface'] = implode(",", $_POST['tftpinterface']);
152
		else
153
			unset($config['system']['tftpinterface']);
154
	
155
		write_config();
156

    
157
		/* 
158
		 * XXX: This is a kludge here but its the better place than on every filter reload.
159
		 * NOTE: This is only for setting the ipfw state limits. 
160
		 */
161
		if ($_POST['maximumstates'] && is_numeric($_POST['maximumstates']) && is_module_loaded("ipfw.ko"))
162
			filter_load_ipfw();
163
			
164
		$retval = 0;
165
		$retval = filter_configure();
166
		if(stristr($retval, "error") <> true)
167
		    $savemsg = get_std_save_message($retval);
168
		else
169
		    $savemsg = $retval;
170
	}
171
}
172

    
173
$pgtitle = array(gettext("System"),gettext("Advanced: Firewall and NAT"));
174
include("head.inc");
175

    
176
?>
177

    
178
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
179
<?php include("fbegin.inc"); ?>
180

    
181
<script language="JavaScript">
182
<!--
183

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

    
190
function update_description(itemnum) {
191
        document.forms[0].info.value=descs[itemnum];
192

    
193
}
194

    
195
//-->
196
</script>
197

    
198
<?php
199
	if ($input_errors)
200
		print_input_errors($input_errors);
201
	if ($savemsg)
202
		print_info_box($savemsg);
203
?>
204
	<form action="system_advanced_firewall.php" method="post" name="iform" id="iform">
205
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
206
			<tr>
207
				<td class="tabnavtbl">
208
					<?php
209
						$tab_array = array();
210
						$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
211
						$tab_array[] = array(gettext("Firewall / NAT"), true, "system_advanced_firewall.php");
212
						$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
213
						$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
214
						$tab_array[] = array(gettext("System Tunables"), false, "system_advanced_sysctl.php");
215
						$tab_array[] = array(gettext("Notifications"), false, "system_advanced_notifications.php");
216
						display_top_tabs($tab_array);
217
					?>
218
				</ul>
219
				</td>
220
			</tr>
221
			<tr>
222
				<td id="mainarea">
223
					<div class="tabcont">
224
						<span class="vexpl">
225
							<span class="red">
226
								<strong><?=gettext("NOTE:");?>&nbsp</strong>
227
							</span>
228
							<?=gettext("The options on this page are intended for use by advanced users only.");?>
229
							<br/>
230
						</span>
231
						<br/>
232
						<table width="100%" border="0" cellpadding="6" cellspacing="0">
233
							<tr>
234
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Firewall Advanced");?></td>
235
							</tr>
236
							<tr>
237
								<td width="22%" valign="top" class="vncell"><?=gettext("IP Do-Not-Fragment compatibility");?></td>
238
								<td width="78%" class="vtable">
239
									<input name="scrubnodf" type="checkbox" id="scrubnodf" value="yes" <?php if (isset($config['system']['scrubnodf'])) echo "checked"; ?> />
240
									<strong><?=gettext("Clear invalid DF bits instead of dropping the packets");?></strong><br/>
241
									<?=gettext("This allows for communications with hosts that generate fragmented " .
242
									"packets with the don't fragment (DF) bit set. Linux NFS is known to " .
243
									"do this. This will cause the filter to not drop such packets but " .
244
									"instead clear the don't fragment bit.");?>
245
								</td>
246
							</tr>
247
							<tr>
248
								<td width="22%" valign="top" class="vncell"><?=gettext("IP Random id generation");?></td>
249
								<td width="78%" class="vtable">
250
									<input name="scrubrnid" type="checkbox" id="scrubnodf" value="yes" <?php if (isset($config['system']['scrubrnid'])) echo "checked"; ?> />
251
									<strong><?=gettext("Insert a stronger id into IP header of packets passing through the filter.");?></strong><br/>
252
									<?=gettext("Replaces the IP identification field of packets with random values to " .
253
									"compensate for operating systems that use predicatable values. " .
254
									"This option only applies to packets that are not fragmented after the " .
255
									"optional packet reassembly.");?>
256
								</td>
257
							</tr>
258
							<tr>
259
								<td width="22%" valign="top" class="vncell"><?=gettext("Firewall Optimization Options");?></td>
260
								<td width="78%" class="vtable">
261
									<select onChange="update_description(this.selectedIndex);" name="optimization" id="optimization">
262
										<option value="normal"<?php if($config['system']['optimization']=="normal") echo " selected"; ?>><?=gettext("normal");?></option>
263
										<option value="high-latency"<?php if($config['system']['optimization']=="high-latency") echo " selected"; ?>><?=gettext("high-latency");?></option>
264
										<option value="aggressive"<?php if($config['system']['optimization']=="aggressive") echo " selected"; ?>><?=gettext("aggressive");?></option>
265
										<option value="conservative"<?php if($config['system']['optimization']=="conservative") echo " selected"; ?>><?=gettext("conservative");?></option>
266
									</select>
267
									<br/>
268
									<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>
269
									<script language="javascript" type="text/javascript">
270
										update_description(document.forms[0].optimization.selectedIndex);
271
									</script>
272
									<br/>
273
									<?=gettext("Select the type of state table optimization to use");?>
274
								</td>
275
							</tr>
276
							<tr>
277
								<td width="22%" valign="top" class="vncell"><?=gettext("Disable Firewall");?></td>
278
								<td width="78%" class="vtable">
279
									<input name="disablefilter" type="checkbox" id="disablefilter" value="yes" <?php if (isset($config['system']['disablefilter'])) echo "checked"; ?> />
280
									<strong><?=gettext("Disable all packet filtering.");?></strong>
281
									<br/>
282
									<span class="vexpl"><?php printf(gettext("Note:  This converts %s into a routing only platform!"), $g['product_name']);?><br>
283
										<?=gettext("Note:  This will turn off NAT!");?>
284
									</span>
285
								</td>
286
							</tr>
287
							<tr>
288
								<td width="22%" valign="top" class="vncell"><?=gettext("Disable Firewall Scrub");?></td>
289
								<td width="78%" class="vtable">
290
									<input name="disablescrub" type="checkbox" id="disablescrub" value="yes" <?php if (isset($config['system']['disablescrub'])) echo "checked"; ?> />
291
									<strong><?=gettext("Disables the PF scrubbing option which can sometimes interfere with NFS and PPTP traffic.");?></strong>
292
									<br/>
293
									<?=gettext("Click")?> <a href='http://www.openbsd.org/faq/pf/scrub.html' target='_new'><?=gettext("here");?></a> <?=gettext("for more information.");?>
294
								</td>
295
							</tr>
296
							<tr>
297
								<td width="22%" valign="top" class="vncell"><?=gettext("Firewall Maximum States");?></td>
298
								<td width="78%" class="vtable">
299
									<input name="maximumstates" type="text" id="maximumstates" value="<?php echo $pconfig['maximumstates']; ?>" />
300
									<br/>
301
									<strong><?=gettext("Maximum number of connections to hold in the firewall state table.");?></strong>
302
									<br/>
303
									<span class="vexpl"><?=gettext("Note:  Leave this blank for the default.  On your system the default size is:");?> <?= pfsense_default_state_size() ?></span>
304
								</td>
305
							</tr>
306
							<tr>
307
								<td width="22%" valign="top" class="vncell"><?=gettext("Firewall Maximum Table Entries");?></td>
308
								<td width="78%" class="vtable">
309
									<input name="maximumtableentries" type="text" id="maximumtableentries" value="<?php echo $pconfig['maximumtableentries']; ?>" />
310
									<br/>
311
									<strong><?=gettext("Maximum number of table entries for systems such as aliases, sshlockout, snort, etc, combined.");?></strong>
312
									<br/>
313
									<span class="vexpl">
314
										<?=gettext("Note:  Leave this blank for the default.");?>
315
										<?php if (empty($pconfig['maximumtableentries'])): ?>
316
											<?= gettext("On your system the default size is:");?> <?= pfsense_default_table_entries_size(); ?>
317
										<?php endif; ?>
318
									</span>
319
								</td>
320
							</tr>
321
							<tr>
322
								<td width="22%" valign="top" class="vncell"><?=gettext("Static route filtering");?></td>
323
								<td width="78%" class="vtable">
324
									<input name="bypassstaticroutes" type="checkbox" id="bypassstaticroutes" value="yes" <?php if ($pconfig['bypassstaticroutes']) echo "checked"; ?> />
325
									<strong><?=gettext("Bypass firewall rules for traffic on the same interface");?></strong>
326
									<br/>
327
									<?=gettext("This option only applies if you have defined one or more static routes. If it is enabled, traffic that enters and " .
328
					 				"leaves through the same interface will not be checked by the firewall. This may be desirable in some situations where " .
329
									"multiple subnets are connected to the same interface.");?>
330
									<br/>
331
								</td>
332
							</tr>
333
							<tr>
334
								<td width="22%" valign="top" class="vncell">Disable reply-to</td>
335
								<td width="78%" class="vtable">
336
									<input name="disablereplyto" type="checkbox" id="disablereplyto" value="yes" <?php if ($pconfig['disablereplyto']) echo "checked"; ?> />
337
									<strong><?=gettext("Disable reply-to on WAN rules");?></strong>
338
									<br />
339
									<?=gettext("With Multi-WAN you generally want to ensure traffic leaves the same interface it arrives on, hence reply-to is added automatically by default. " .
340
									"When using bridging, you must disable this behavior if the WAN gateway IP is different from the gateway IP of the hosts behind the bridged interface.");?>
341
									<br />
342
								</td>
343
							</tr>
344
							<tr>
345
								<td colspan="2" class="list" height="12">&nbsp;</td>
346
							</tr>
347
							<?php if(count($config['interfaces']) > 1): ?>
348
							<tr>
349
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Network Address Translation");?></td>
350
							</tr>		
351
							<tr>
352
								<td width="22%" valign="top" class="vncell"><?=gettext("Disable NAT Reflection for port forwards");?></td>
353
								<td width="78%" class="vtable">
354
									<input name="disablenatreflection" type="checkbox" id="disablenatreflection" value="yes" <?php if (isset($config['system']['disablenatreflection'])) echo "checked"; ?> />
355
									<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>
356
								</td>
357
							</tr>
358
							<tr>
359
								<td width="22%" valign="top" class="vncell"><?=gettext("Reflection Timeout");?></td>
360
								<td width="78%" class="vtable">
361
									<input name="reflectiontimeout" id="reflectiontimeout" value="<?php echo $config['system']['reflectiontimeout']; ?>" /><br/>
362
									<strong><?=gettext("Enter value for Reflection timeout in seconds.  Note: Only applies to Reflection on port forwards.");?></strong>
363
								</td>
364
							</tr>
365
							<tr>
366
								<td width="22%" valign="top" class="vncell"><?=gettext("Disable NAT Reflection for 1:1 NAT");?></td>
367
								<td width="78%" class="vtable">
368
									<input name="disablebinatreflection" type="checkbox" id="disablebinatreflection" value="yes" <?php if (!isset($config['system']['enablebinatreflection'])) echo "checked"; ?> />
369
									<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>
370
								</td>
371
							</tr>
372
							<tr>
373
								<td width="22%" valign="top" class="vncell">&nbsp;</td>
374
								<td width="78%" class="vtable">
375
									<input name="enablenatreflectionhelper" type="checkbox" id="enablenatreflectionhelper" value="yes" <?php if (isset($config['system']['enablenatreflectionhelper'])) echo "checked"; ?> />
376
									<strong><?=gettext("Automatically create outbound NAT rules which assist inbound NAT rules that direct traffic back out to the same subnet it originated from.");?></strong>
377
									<br/>
378
									<?=gettext("Currently only applies to 1:1 NAT rules.  Required for full functionality of NAT Reflection for 1:1 NAT.");?>
379
								</td>
380
							</tr>
381
							<tr>
382
								<td width="22%" valign="top" class="vncell"><?=gettext("TFTP Proxy");?></td>
383
								<td width="78%" class="vtable">
384
									<select name="tftpinterface[]" multiple="true" class="formselect" size="3">
385
<?php
386
										$ifdescs = get_configured_interface_with_descr();
387
										foreach ($ifdescs as $ifent => $ifdesc):
388
?>
389
											<option value="<?=$ifent;?>" <?php if (in_array($ifent, $pconfig['tftpinterface'])) echo "selected"; ?>><?=gettext($ifdesc);?></option>
390
<?php									endforeach; ?>
391
									</select>
392
									<strong><?=gettext("Choose the interfaces where you want TFTP proxy helper to be enabled.");?></strong>
393
								</td>
394
							</tr>
395
							<tr>
396
								<td colspan="2" class="list" height="12">&nbsp;</td>
397
							</tr>
398
							<?php endif; ?>
399
							<tr>
400
								<td width="22%" valign="top">&nbsp;</td>
401
								<td width="78%"><input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" /></td>
402
							</tr>
403
						</table>
404
					</td>
405
				</tr>
406
			</div>
407
		</table>
408
	</form>
409

    
410
<?php include("fend.inc"); ?>
411
</body>
412
</html>
413

    
(178-178/225)