Project

General

Profile

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

    
72
if ($_POST) {
73

    
74
	unset($input_errors);
75
	$pconfig = $_POST;
76

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

    
91
    ob_flush();
92
    flush();
93

    
94
	if (!$input_errors) {
95

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

    
101
		if($_POST['disablevpnrules'] == "yes")
102
			$config['system']['disablevpnrules'] = true;
103
		else
104
			unset($config['system']['disablevpnrules']);
105
		if($_POST['rfc959workaround'] == "yes")
106
			$config['system']['rfc959workaround'] = "enabled";
107
		else
108
			unset($config['system']['rfc959workaround']);
109

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

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

    
120
		$config['system']['optimization'] = $_POST['optimization'];
121
		$config['system']['maximumstates'] = $_POST['maximumstates'];
122
		$config['system']['maximumtableentries'] = $_POST['maximumtableentries'];
123

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

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

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

    
139
		if($_POST['disablenegate'] == "yes")
140
                        $config['system']['disablenegate'] = $_POST['disablenegate'];
141
                else
142
                        unset($config['system']['disablenegate']);
143

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

    
149
		$config['system']['reflectiontimeout'] = $_POST['reflectiontimeout'];
150

    
151
		if($_POST['bypassstaticroutes'] == "yes")
152
			$config['filter']['bypassstaticroutes'] = $_POST['bypassstaticroutes'];
153
		elseif(isset($config['filter']['bypassstaticroutes']))
154
			unset($config['filter']['bypassstaticroutes']);
155

    
156
		if($_POST['disablescrub'] == "yes")
157
			$config['system']['disablescrub'] = $_POST['disablescrub'];
158
		else
159
			unset($config['system']['disablescrub']);
160

    
161
		if ($_POST['tftpinterface'])
162
			$config['system']['tftpinterface'] = implode(",", $_POST['tftpinterface']);
163
		else
164
			unset($config['system']['tftpinterface']);
165
	
166
		write_config();
167

    
168
		/* 
169
		 * XXX: This is a kludge here but its the better place than on every filter reload.
170
		 * NOTE: This is only for setting the ipfw state limits. 
171
		 */
172
		if ($_POST['maximumstates'] && is_numeric($_POST['maximumstates']) && is_module_loaded("ipfw.ko"))
173
			filter_load_ipfw();
174
			
175
		$retval = 0;
176
		$retval = filter_configure();
177
		if(stristr($retval, "error") <> true)
178
		    $savemsg = get_std_save_message($retval);
179
		else
180
		    $savemsg = $retval;
181
	}
182
}
183

    
184
$pgtitle = array(gettext("System"),gettext("Advanced: Firewall and NAT"));
185
include("head.inc");
186

    
187
?>
188

    
189
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
190
<?php include("fbegin.inc"); ?>
191

    
192
<script language="JavaScript">
193
<!--
194

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

    
201
function update_description(itemnum) {
202
        document.forms[0].info.value=descs[itemnum];
203

    
204
}
205

    
206
//-->
207
</script>
208

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

    
441
<?php include("fend.inc"); ?>
442
</body>
443
</html>
444

    
(190-190/239)