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 |
|
|
$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 |
|
|
|
63 |
|
|
if ($_POST) {
|
64 |
|
|
|
65 |
|
|
unset($input_errors);
|
66 |
|
|
$pconfig = $_POST;
|
67 |
|
|
|
68 |
|
|
/* input validation */
|
69 |
|
|
if ($_POST['maximumstates'] && !is_numericint($_POST['maximumstates'])) {
|
70 |
|
|
$input_errors[] = "The Firewall Maximum States value must be an integer.";
|
71 |
|
|
}
|
72 |
|
|
if ($_POST['tcpidletimeout'] && !is_numericint($_POST['tcpidletimeout'])) {
|
73 |
|
|
$input_errors[] = "The TCP idle timeout must be an integer.";
|
74 |
|
|
}
|
75 |
|
|
if ($_POST['reflectiontimeout'] && !is_numericint($_POST['reflectiontimeout'])) {
|
76 |
|
|
$input_errors[] = "The Reflection timeout must be an integer.";
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
ob_flush();
|
80 |
|
|
flush();
|
81 |
|
|
|
82 |
|
|
if (!$input_errors) {
|
83 |
|
|
|
84 |
|
|
if($_POST['disablefilter'] == "yes")
|
85 |
|
|
$config['system']['disablefilter'] = "enabled";
|
86 |
|
|
else
|
87 |
|
|
unset($config['system']['disablefilter']);
|
88 |
|
|
|
89 |
|
|
if($_POST['rfc959workaround'] == "yes")
|
90 |
|
|
$config['system']['rfc959workaround'] = "enabled";
|
91 |
|
|
else
|
92 |
|
|
unset($config['system']['rfc959workaround']);
|
93 |
|
|
|
94 |
|
|
if($_POST['scrubnodf'] == "yes")
|
95 |
|
|
$config['system']['scrubnodf'] = "enabled";
|
96 |
|
|
else
|
97 |
|
|
unset($config['system']['scrubnodf']);
|
98 |
|
|
|
99 |
2867fa7b
|
Ermal Luçi
|
if($_POST['scrubrnid'] == "yes")
|
100 |
|
|
$config['system']['scrubrnid'] = "enabled";
|
101 |
|
|
else
|
102 |
|
|
unset($config['system']['scrubrnid']);
|
103 |
|
|
|
104 |
df81417f
|
Matthew Grooms
|
$config['system']['optimization'] = $_POST['optimization'];
|
105 |
|
|
$config['system']['maximumstates'] = $_POST['maximumstates'];
|
106 |
|
|
|
107 |
|
|
if($_POST['disablenatreflection'] == "yes")
|
108 |
|
|
$config['system']['disablenatreflection'] = $_POST['disablenatreflection'];
|
109 |
|
|
else
|
110 |
|
|
unset($config['system']['disablenatreflection']);
|
111 |
|
|
|
112 |
|
|
$config['system']['reflectiontimeout'] = $_POST['reflectiontimeout'];
|
113 |
|
|
|
114 |
|
|
if($_POST['bypassstaticroutes'] == "yes")
|
115 |
668c4990
|
Seth Mos
|
$config['filter']['bypassstaticroutes'] = $_POST['bypassstaticroutes'];
|
116 |
df81417f
|
Matthew Grooms
|
else
|
117 |
668c4990
|
Seth Mos
|
unset($config['filter']['bypassstaticroutes']);
|
118 |
df81417f
|
Matthew Grooms
|
|
119 |
|
|
if($_POST['disablescrub'] == "yes")
|
120 |
|
|
$config['system']['disablescrub'] = $_POST['disablescrub'];
|
121 |
|
|
else
|
122 |
|
|
unset($config['system']['disablescrub']);
|
123 |
|
|
|
124 |
|
|
write_config();
|
125 |
|
|
|
126 |
bd448e7f
|
Ermal Lu?i
|
/*
|
127 |
|
|
* XXX: This is a kludge here but its the better place than on every filter reload.
|
128 |
|
|
* NOTE: This is only for setting the ipfw state limits.
|
129 |
|
|
*/
|
130 |
|
|
if ($_POST['maximumstates'] && is_numeric($_POST['maximumstates']) && is_module_loaded("ipfw.ko"))
|
131 |
|
|
filter_load_ipfw();
|
132 |
|
|
|
133 |
df81417f
|
Matthew Grooms
|
$retval = 0;
|
134 |
|
|
$retval = filter_configure();
|
135 |
|
|
if(stristr($retval, "error") <> true)
|
136 |
|
|
$savemsg = get_std_save_message($retval);
|
137 |
|
|
else
|
138 |
|
|
$savemsg = $retval;
|
139 |
|
|
}
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
$pgtitle = array("System","Advanced: Firewall and NAT");
|
143 |
|
|
include("head.inc");
|
144 |
|
|
|
145 |
|
|
?>
|
146 |
|
|
|
147 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
148 |
|
|
<?php include("fbegin.inc"); ?>
|
149 |
|
|
|
150 |
|
|
<script language="JavaScript">
|
151 |
|
|
<!--
|
152 |
|
|
|
153 |
|
|
var descs=new Array(5);
|
154 |
|
|
descs[0]="as the name says, it's the normal optimization algorithm";
|
155 |
|
|
descs[1]="used for high latency links, such as satellite links. Expires idle connections later than default";
|
156 |
|
|
descs[2]="expires idle connections quicker. More efficient use of CPU and memory but can drop legitimate connections";
|
157 |
|
|
descs[3]="tries to avoid dropping any legitimate connections at the expense of increased memory usage and CPU utilization.";
|
158 |
|
|
|
159 |
|
|
function update_description(itemnum) {
|
160 |
|
|
document.forms[0].info.value=descs[itemnum];
|
161 |
|
|
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
//-->
|
165 |
|
|
</script>
|
166 |
|
|
|
167 |
|
|
<?php
|
168 |
|
|
if ($input_errors)
|
169 |
|
|
print_input_errors($input_errors);
|
170 |
|
|
if ($savemsg)
|
171 |
|
|
print_info_box($savemsg);
|
172 |
|
|
?>
|
173 |
ab3c8553
|
Matthew Grooms
|
<form action="system_advanced_firewall.php" method="post" name="iform" id="iform">
|
174 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
175 |
|
|
<tr>
|
176 |
|
|
<td class="tabnavtbl">
|
177 |
|
|
<?php
|
178 |
|
|
$tab_array = array();
|
179 |
|
|
$tab_array[] = array("Admin Access", false, "system_advanced_admin.php");
|
180 |
|
|
$tab_array[] = array("Firewall / NAT", true, "system_advanced_firewall.php");
|
181 |
|
|
$tab_array[] = array("Networking", false, "system_advanced_network.php");
|
182 |
|
|
$tab_array[] = array("Miscellaneous", false, "system_advanced_misc.php");
|
183 |
|
|
$tab_array[] = array("System Tunables", false, "system_advanced_sysctl.php");
|
184 |
487b16ec
|
Scott Ullrich
|
$tab_array[] = array("Notifications", false, "system_advanced_notifications.php");
|
185 |
ab3c8553
|
Matthew Grooms
|
display_top_tabs($tab_array);
|
186 |
|
|
?>
|
187 |
df81417f
|
Matthew Grooms
|
</ul>
|
188 |
ab3c8553
|
Matthew Grooms
|
</td>
|
189 |
|
|
</tr>
|
190 |
|
|
<tr>
|
191 |
2ff19bfd
|
Matthew Grooms
|
<td id="mainarea">
|
192 |
|
|
<div class="tabcont">
|
193 |
|
|
<span class="vexpl">
|
194 |
|
|
<span class="red">
|
195 |
|
|
<strong>NOTE: </strong>
|
196 |
|
|
</span>
|
197 |
|
|
The options on this page are intended for use by advanced users only.
|
198 |
|
|
<br/>
|
199 |
|
|
</span>
|
200 |
|
|
<br/>
|
201 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
202 |
ab3c8553
|
Matthew Grooms
|
<tr>
|
203 |
|
|
<td colspan="2" valign="top" class="listtopic">Firewall Advanced</td>
|
204 |
|
|
</tr>
|
205 |
|
|
<tr>
|
206 |
|
|
<td width="22%" valign="top" class="vncell">IP Do-Not-Fragment compatibility</td>
|
207 |
|
|
<td width="78%" class="vtable">
|
208 |
|
|
<input name="scrubnodf" type="checkbox" id="scrubnodf" value="yes" <?php if (isset($config['system']['scrubnodf'])) echo "checked"; ?> />
|
209 |
|
|
<strong>Clear invalid DF bits instead of dropping the packets</strong><br/>
|
210 |
|
|
This allows for communications with hosts that generate fragmented
|
211 |
|
|
packets with the don't fragment (DF) bit set. Linux NFS is known to
|
212 |
|
|
do this. This will cause the filter to not drop such packets but
|
213 |
2867fa7b
|
Ermal Luçi
|
instead clear the don't fragment bit.
|
214 |
|
|
</td>
|
215 |
|
|
</tr>
|
216 |
|
|
<tr>
|
217 |
|
|
<td width="22%" valign="top" class="vncell">IP Random id generation</td>
|
218 |
|
|
<td width="78%" class="vtable">
|
219 |
|
|
<input name="scrubrnid" type="checkbox" id="scrubnodf" value="yes" <?php if (isset($config['system']['scrubrnid'])) echo "checked"; ?> />
|
220 |
|
|
<strong>Insert a stronger id into IP header of packets passing through the filter.</strong><br/>
|
221 |
|
|
Replaces the IP identification field of packets with random values to
|
222 |
|
|
compensate for operating systems that use predicatable values.
|
223 |
|
|
This option only applies to packets that are not fragmented after the
|
224 |
|
|
optional packet reassembly.
|
225 |
ab3c8553
|
Matthew Grooms
|
</td>
|
226 |
|
|
</tr>
|
227 |
|
|
<tr>
|
228 |
|
|
<td width="22%" valign="top" class="vncell">Firewall Optimization Options</td>
|
229 |
|
|
<td width="78%" class="vtable">
|
230 |
|
|
<select onChange="update_description(this.selectedIndex);" name="optimization" id="optimization">
|
231 |
|
|
<option value="normal"<?php if($config['system']['optimization']=="normal") echo " selected"; ?>>normal</option>
|
232 |
|
|
<option value="high-latency"<?php if($config['system']['optimization']=="high-latency") echo " selected"; ?>>high-latency</option>
|
233 |
|
|
<option value="aggressive"<?php if($config['system']['optimization']=="aggressive") echo " selected"; ?>>aggressive</option>
|
234 |
|
|
<option value="conservative"<?php if($config['system']['optimization']=="conservative") echo " selected"; ?>>conservative</option>
|
235 |
|
|
</select>
|
236 |
|
|
<br/>
|
237 |
|
|
<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>
|
238 |
|
|
<script language="javascript" type="text/javascript">
|
239 |
|
|
update_description(document.forms[0].optimization.selectedIndex);
|
240 |
|
|
</script>
|
241 |
|
|
<br/>
|
242 |
|
|
Select which type of state table optimization your would like to use
|
243 |
|
|
</td>
|
244 |
|
|
</tr>
|
245 |
|
|
<tr>
|
246 |
|
|
<td width="22%" valign="top" class="vncell">Disable Firewall</td>
|
247 |
|
|
<td width="78%" class="vtable">
|
248 |
|
|
<input name="disablefilter" type="checkbox" id="disablefilter" value="yes" <?php if (isset($config['system']['disablefilter'])) echo "checked"; ?> />
|
249 |
|
|
<strong>Disable all packet filtering.</strong>
|
250 |
|
|
<br/>
|
251 |
|
|
<span class="vexpl">Note: This converts <?= $g['product_name'] ?> into a routing only platform!<br>
|
252 |
|
|
Note: This will turn off NAT!
|
253 |
|
|
</span>
|
254 |
|
|
</td>
|
255 |
|
|
</tr>
|
256 |
|
|
<tr>
|
257 |
|
|
<td width="22%" valign="top" class="vncell">Disable Firewall Scrub</td>
|
258 |
|
|
<td width="78%" class="vtable">
|
259 |
|
|
<input name="disablescrub" type="checkbox" id="disablescrub" value="yes" <?php if (isset($config['system']['disablescrub'])) echo "checked"; ?> />
|
260 |
|
|
<strong>Disables the PF scrubbing option which can sometimes interfere with NFS and PPTP traffic.</strong>
|
261 |
|
|
<br/>
|
262 |
|
|
Click <a href='http://www.openbsd.org/faq/pf/scrub.html' target='_new'>here</a> for more information.
|
263 |
|
|
</td>
|
264 |
|
|
</tr>
|
265 |
|
|
<tr>
|
266 |
|
|
<td width="22%" valign="top" class="vncell">Firewall Maximum States</td>
|
267 |
|
|
<td width="78%" class="vtable">
|
268 |
|
|
<input name="maximumstates" type="text" id="maximumstates" value="<?php echo $pconfig['maximumstates']; ?>" />
|
269 |
|
|
<br/>
|
270 |
|
|
<strong>Maximum number of connections to hold in the firewall state table.</strong>
|
271 |
|
|
<br/>
|
272 |
|
|
<span class="vexpl">Note: Leave this blank for the default. On your system the default size is: <?= pfsense_default_state_size() ?></span>
|
273 |
|
|
</td>
|
274 |
|
|
</tr>
|
275 |
|
|
<tr>
|
276 |
|
|
<td width="22%" valign="top" class="vncell">Static route filtering</td>
|
277 |
|
|
<td width="78%" class="vtable">
|
278 |
|
|
<input name="bypassstaticroutes" type="checkbox" id="bypassstaticroutes" value="yes" <?php if ($pconfig['bypassstaticroutes']) echo "checked"; ?> />
|
279 |
|
|
<strong>Bypass firewall rules for traffic on the same interface</strong>
|
280 |
|
|
<br/>
|
281 |
|
|
This option only applies if you have defined one or more static routes. If it is enabled, traffic that enters and
|
282 |
|
|
leaves through the same interface will not be checked by the firewall. This may be desirable in some situations where
|
283 |
|
|
multiple subnets are connected to the same interface.
|
284 |
|
|
<br/>
|
285 |
|
|
</td>
|
286 |
|
|
</tr>
|
287 |
|
|
<tr>
|
288 |
|
|
<td colspan="2" class="list" height="12"> </td>
|
289 |
|
|
</tr>
|
290 |
|
|
<?php if($config['interfaces']['lan']): ?>
|
291 |
|
|
<tr>
|
292 |
|
|
<td colspan="2" valign="top" class="listtopic">Network Address Translation</td>
|
293 |
|
|
</tr>
|
294 |
|
|
<tr>
|
295 |
|
|
<td width="22%" valign="top" class="vncell">Disable NAT Reflection</td>
|
296 |
|
|
<td width="78%" class="vtable">
|
297 |
|
|
<input name="disablenatreflection" type="checkbox" id="disablenatreflection" value="yes" <?php if (isset($config['system']['disablenatreflection'])) echo "checked"; ?> />
|
298 |
|
|
<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>
|
299 |
|
|
</td>
|
300 |
|
|
</tr>
|
301 |
|
|
<tr>
|
302 |
|
|
<td width="22%" valign="top" class="vncell">Reflection Timeout</td>
|
303 |
|
|
<td width="78%" class="vtable">
|
304 |
d231c4d3
|
Scott Ullrich
|
<input name="reflectiontimeout" id="reflectiontimeout" value="<?php echo $config['system']['reflectiontimeout']; ?>" /><br/>
|
305 |
ab3c8553
|
Matthew Grooms
|
<strong>Enter value for Reflection timeout in seconds.</strong>
|
306 |
|
|
</td>
|
307 |
|
|
</tr>
|
308 |
|
|
<tr>
|
309 |
|
|
<td colspan="2" class="list" height="12"> </td>
|
310 |
|
|
</tr>
|
311 |
|
|
<?php endif; ?>
|
312 |
|
|
<tr>
|
313 |
|
|
<td width="22%" valign="top"> </td>
|
314 |
|
|
<td width="78%"><input name="Submit" type="submit" class="formbtn" value="Save" /></td>
|
315 |
|
|
</tr>
|
316 |
|
|
</table>
|
317 |
|
|
</td>
|
318 |
|
|
</tr>
|
319 |
|
|
</div>
|
320 |
|
|
</table>
|
321 |
|
|
</form>
|
322 |
df81417f
|
Matthew Grooms
|
|
323 |
|
|
<?php include("fend.inc"); ?>
|
324 |
|
|
</body>
|
325 |
|
|
</html>
|