1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
5ba18897
|
Scott Ullrich
|
<?php
|
3 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
4 |
5b237745
|
Scott Ullrich
|
/*
|
5 |
bdb7d6e7
|
Scott Ullrich
|
firewall_rules_edit.php
|
6 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
7 |
5ba18897
|
Scott Ullrich
|
|
8 |
bdb7d6e7
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
9 |
|
|
All rights reserved.
|
10 |
5ba18897
|
Scott Ullrich
|
|
11 |
bdb7d6e7
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, are permitted provided that the following conditions are met:
|
13 |
5ba18897
|
Scott Ullrich
|
|
14 |
bdb7d6e7
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
this list of conditions and the following disclaimer.
|
16 |
5ba18897
|
Scott Ullrich
|
|
17 |
bdb7d6e7
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
5ba18897
|
Scott Ullrich
|
|
21 |
bdb7d6e7
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
5b237745
|
Scott Ullrich
|
*/
|
32 |
|
|
|
33 |
|
|
require("guiconfig.inc");
|
34 |
|
|
|
35 |
|
|
$specialsrcdst = explode(" ", "any lan pptp");
|
36 |
|
|
|
37 |
|
|
if (!is_array($config['filter']['rule'])) {
|
38 |
|
|
$config['filter']['rule'] = array();
|
39 |
|
|
}
|
40 |
|
|
filter_rules_sort();
|
41 |
|
|
$a_filter = &$config['filter']['rule'];
|
42 |
|
|
|
43 |
|
|
$id = $_GET['id'];
|
44 |
|
|
if (is_numeric($_POST['id']))
|
45 |
|
|
$id = $_POST['id'];
|
46 |
5ba18897
|
Scott Ullrich
|
|
47 |
5b237745
|
Scott Ullrich
|
$after = $_GET['after'];
|
48 |
|
|
|
49 |
|
|
if (isset($_POST['after']))
|
50 |
|
|
$after = $_POST['after'];
|
51 |
|
|
|
52 |
|
|
if (isset($_GET['dup'])) {
|
53 |
|
|
$id = $_GET['dup'];
|
54 |
|
|
$after = $_GET['dup'];
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
if (isset($id) && $a_filter[$id]) {
|
58 |
|
|
$pconfig['interface'] = $a_filter[$id]['interface'];
|
59 |
5ba18897
|
Scott Ullrich
|
|
60 |
5b237745
|
Scott Ullrich
|
if (!isset($a_filter[$id]['type']))
|
61 |
|
|
$pconfig['type'] = "pass";
|
62 |
|
|
else
|
63 |
|
|
$pconfig['type'] = $a_filter[$id]['type'];
|
64 |
5ba18897
|
Scott Ullrich
|
|
65 |
5b237745
|
Scott Ullrich
|
if (isset($a_filter[$id]['protocol']))
|
66 |
|
|
$pconfig['proto'] = $a_filter[$id]['protocol'];
|
67 |
|
|
else
|
68 |
|
|
$pconfig['proto'] = "any";
|
69 |
5ba18897
|
Scott Ullrich
|
|
70 |
5b237745
|
Scott Ullrich
|
if ($a_filter[$id]['protocol'] == "icmp")
|
71 |
|
|
$pconfig['icmptype'] = $a_filter[$id]['icmptype'];
|
72 |
5ba18897
|
Scott Ullrich
|
|
73 |
5b237745
|
Scott Ullrich
|
address_to_pconfig($a_filter[$id]['source'], $pconfig['src'],
|
74 |
|
|
$pconfig['srcmask'], $pconfig['srcnot'],
|
75 |
|
|
$pconfig['srcbeginport'], $pconfig['srcendport']);
|
76 |
5ba18897
|
Scott Ullrich
|
|
77 |
8be60f21
|
Scott Ullrich
|
if($a_filter[$id]['os'] <> "")
|
78 |
|
|
$pconfig['os'] = $a_filter[$id]['os'];
|
79 |
e33c8694
|
Bill Marquette
|
|
80 |
5b237745
|
Scott Ullrich
|
address_to_pconfig($a_filter[$id]['destination'], $pconfig['dst'],
|
81 |
|
|
$pconfig['dstmask'], $pconfig['dstnot'],
|
82 |
|
|
$pconfig['dstbeginport'], $pconfig['dstendport']);
|
83 |
|
|
|
84 |
|
|
$pconfig['disabled'] = isset($a_filter[$id]['disabled']);
|
85 |
|
|
$pconfig['log'] = isset($a_filter[$id]['log']);
|
86 |
|
|
$pconfig['descr'] = $a_filter[$id]['descr'];
|
87 |
ed08ef3e
|
Scott Ullrich
|
|
88 |
|
|
/* advanced */
|
89 |
fa9af164
|
Scott Ullrich
|
$pconfig['max-src-nodes'] = $a_filter[$id]['max-src-nodes'];
|
90 |
|
|
$pconfig['max-src-states'] = $a_filter[$id]['max-src-states'];
|
91 |
|
|
$pconfig['statetype'] = $a_filter[$id]['statetype'];
|
92 |
5ba18897
|
Scott Ullrich
|
$pconfig['statetimeout'] = $a_filter[$id]['statetimeout'];
|
93 |
ed08ef3e
|
Scott Ullrich
|
|
94 |
|
|
/* advanced - new connection per second banning*/
|
95 |
|
|
$pconfig['max-src-conn-rate'] = $a_filter[$id]['max-src-conn-rate'];
|
96 |
|
|
$pconfig['max-src-conn-rates'] = $a_filter[$id]['max-src-conn-rates'];
|
97 |
5ba18897
|
Scott Ullrich
|
|
98 |
5b237745
|
Scott Ullrich
|
} else {
|
99 |
|
|
/* defaults */
|
100 |
a23d7248
|
Scott Ullrich
|
if ($_GET['if'])
|
101 |
|
|
$pconfig['interface'] = $_GET['if'];
|
102 |
5b237745
|
Scott Ullrich
|
$pconfig['type'] = "pass";
|
103 |
|
|
$pconfig['src'] = "any";
|
104 |
|
|
$pconfig['dst'] = "any";
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
if (isset($_GET['dup']))
|
108 |
|
|
unset($id);
|
109 |
|
|
|
110 |
|
|
if ($_POST) {
|
111 |
|
|
|
112 |
|
|
if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "tcp/udp")) {
|
113 |
|
|
$_POST['srcbeginport'] = 0;
|
114 |
|
|
$_POST['srcendport'] = 0;
|
115 |
|
|
$_POST['dstbeginport'] = 0;
|
116 |
|
|
$_POST['dstendport'] = 0;
|
117 |
|
|
} else {
|
118 |
5ba18897
|
Scott Ullrich
|
|
119 |
5b237745
|
Scott Ullrich
|
if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
|
120 |
|
|
$_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
|
121 |
|
|
if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
|
122 |
|
|
$_POST['srcendport'] = $_POST['srcendport_cust'];
|
123 |
5ba18897
|
Scott Ullrich
|
|
124 |
5b237745
|
Scott Ullrich
|
if ($_POST['srcbeginport'] == "any") {
|
125 |
|
|
$_POST['srcbeginport'] = 0;
|
126 |
|
|
$_POST['srcendport'] = 0;
|
127 |
5ba18897
|
Scott Ullrich
|
} else {
|
128 |
5b237745
|
Scott Ullrich
|
if (!$_POST['srcendport'])
|
129 |
|
|
$_POST['srcendport'] = $_POST['srcbeginport'];
|
130 |
|
|
}
|
131 |
|
|
if ($_POST['srcendport'] == "any")
|
132 |
|
|
$_POST['srcendport'] = $_POST['srcbeginport'];
|
133 |
5ba18897
|
Scott Ullrich
|
|
134 |
5b237745
|
Scott Ullrich
|
if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
|
135 |
|
|
$_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
|
136 |
|
|
if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
|
137 |
|
|
$_POST['dstendport'] = $_POST['dstendport_cust'];
|
138 |
5ba18897
|
Scott Ullrich
|
|
139 |
5b237745
|
Scott Ullrich
|
if ($_POST['dstbeginport'] == "any") {
|
140 |
|
|
$_POST['dstbeginport'] = 0;
|
141 |
|
|
$_POST['dstendport'] = 0;
|
142 |
5ba18897
|
Scott Ullrich
|
} else {
|
143 |
5b237745
|
Scott Ullrich
|
if (!$_POST['dstendport'])
|
144 |
|
|
$_POST['dstendport'] = $_POST['dstbeginport'];
|
145 |
|
|
}
|
146 |
|
|
if ($_POST['dstendport'] == "any")
|
147 |
5ba18897
|
Scott Ullrich
|
$_POST['dstendport'] = $_POST['dstbeginport'];
|
148 |
5b237745
|
Scott Ullrich
|
}
|
149 |
5ba18897
|
Scott Ullrich
|
|
150 |
5b237745
|
Scott Ullrich
|
if (is_specialnet($_POST['srctype'])) {
|
151 |
|
|
$_POST['src'] = $_POST['srctype'];
|
152 |
|
|
$_POST['srcmask'] = 0;
|
153 |
|
|
} else if ($_POST['srctype'] == "single") {
|
154 |
|
|
$_POST['srcmask'] = 32;
|
155 |
|
|
}
|
156 |
|
|
if (is_specialnet($_POST['dsttype'])) {
|
157 |
|
|
$_POST['dst'] = $_POST['dsttype'];
|
158 |
|
|
$_POST['dstmask'] = 0;
|
159 |
|
|
} else if ($_POST['dsttype'] == "single") {
|
160 |
|
|
$_POST['dstmask'] = 32;
|
161 |
|
|
}
|
162 |
5ba18897
|
Scott Ullrich
|
|
163 |
5b237745
|
Scott Ullrich
|
unset($input_errors);
|
164 |
|
|
$pconfig = $_POST;
|
165 |
|
|
|
166 |
|
|
/* input validation */
|
167 |
|
|
$reqdfields = explode(" ", "type interface proto src dst");
|
168 |
|
|
$reqdfieldsn = explode(",", "Type,Interface,Protocol,Source,Destination");
|
169 |
|
|
|
170 |
bdb7d6e7
|
Scott Ullrich
|
|
171 |
|
|
if($_POST['statetype'] == "modulate state" or $_POST['statetype'] == "synproxy state")
|
172 |
c22767b1
|
Bill Marquette
|
if( $_POST['proto'] != "tcp" )
|
173 |
|
|
$input_errors[] = "{$_POST['statetype']} is only valid with protocol tcp.";
|
174 |
bdb7d6e7
|
Scott Ullrich
|
|
175 |
5ba18897
|
Scott Ullrich
|
|
176 |
5b237745
|
Scott Ullrich
|
if (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) {
|
177 |
|
|
$reqdfields[] = "srcmask";
|
178 |
|
|
$reqdfieldsn[] = "Source bit count";
|
179 |
|
|
}
|
180 |
|
|
if (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) {
|
181 |
|
|
$reqdfields[] = "dstmask";
|
182 |
|
|
$reqdfieldsn[] = "Destination bit count";
|
183 |
|
|
}
|
184 |
5ba18897
|
Scott Ullrich
|
|
185 |
5b237745
|
Scott Ullrich
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
186 |
5ba18897
|
Scott Ullrich
|
|
187 |
5b237745
|
Scott Ullrich
|
if (!$_POST['srcbeginport']) {
|
188 |
|
|
$_POST['srcbeginport'] = 0;
|
189 |
|
|
$_POST['srcendport'] = 0;
|
190 |
|
|
}
|
191 |
|
|
if (!$_POST['dstbeginport']) {
|
192 |
|
|
$_POST['dstbeginport'] = 0;
|
193 |
|
|
$_POST['dstendport'] = 0;
|
194 |
|
|
}
|
195 |
5ba18897
|
Scott Ullrich
|
|
196 |
19757279
|
Scott Ullrich
|
if (($_POST['srcbeginport'] && !alias_expand($_POST['srcbeginport']) && !is_port($_POST['srcbeginport']))) {
|
197 |
aba8aace
|
Scott Ullrich
|
$input_errors[] = "The start source port must be an alias or integer between 1 and 65535.";
|
198 |
bdb7d6e7
|
Scott Ullrich
|
}
|
199 |
19757279
|
Scott Ullrich
|
if (($_POST['srcendport'] && !alias_expand($_POST['srcendport']) && !is_port($_POST['srcendport']))) {
|
200 |
aba8aace
|
Scott Ullrich
|
$input_errors[] = "The end source port must be an alias or integer between 1 and 65535.";
|
201 |
bdb7d6e7
|
Scott Ullrich
|
}
|
202 |
19757279
|
Scott Ullrich
|
if (($_POST['dstbeginport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstbeginport']))) {
|
203 |
aba8aace
|
Scott Ullrich
|
$input_errors[] = "The start destination port must be an alias or integer between 1 and 65535.";
|
204 |
bdb7d6e7
|
Scott Ullrich
|
}
|
205 |
19757279
|
Scott Ullrich
|
if (($_POST['dstendport'] && !alias_expand($_POST['dstbeginport']) && !is_port($_POST['dstendport']))) {
|
206 |
aba8aace
|
Scott Ullrich
|
$input_errors[] = "The end destination port must be an alias or integer between 1 and 65535.";
|
207 |
bdb7d6e7
|
Scott Ullrich
|
}
|
208 |
5ba18897
|
Scott Ullrich
|
|
209 |
5b237745
|
Scott Ullrich
|
if (!is_specialnet($_POST['srctype'])) {
|
210 |
|
|
if (($_POST['src'] && !is_ipaddroranyalias($_POST['src']))) {
|
211 |
|
|
$input_errors[] = "A valid source IP address or alias must be specified.";
|
212 |
|
|
}
|
213 |
|
|
if (($_POST['srcmask'] && !is_numericint($_POST['srcmask']))) {
|
214 |
|
|
$input_errors[] = "A valid source bit count must be specified.";
|
215 |
|
|
}
|
216 |
|
|
}
|
217 |
|
|
if (!is_specialnet($_POST['dsttype'])) {
|
218 |
|
|
if (($_POST['dst'] && !is_ipaddroranyalias($_POST['dst']))) {
|
219 |
|
|
$input_errors[] = "A valid destination IP address or alias must be specified.";
|
220 |
|
|
}
|
221 |
|
|
if (($_POST['dstmask'] && !is_numericint($_POST['dstmask']))) {
|
222 |
|
|
$input_errors[] = "A valid destination bit count must be specified.";
|
223 |
|
|
}
|
224 |
|
|
}
|
225 |
5ba18897
|
Scott Ullrich
|
|
226 |
5b237745
|
Scott Ullrich
|
if ($_POST['srcbeginport'] > $_POST['srcendport']) {
|
227 |
|
|
/* swap */
|
228 |
|
|
$tmp = $_POST['srcendport'];
|
229 |
|
|
$_POST['srcendport'] = $_POST['srcbeginport'];
|
230 |
|
|
$_POST['srcbeginport'] = $tmp;
|
231 |
|
|
}
|
232 |
|
|
if ($_POST['dstbeginport'] > $_POST['dstendport']) {
|
233 |
|
|
/* swap */
|
234 |
|
|
$tmp = $_POST['dstendport'];
|
235 |
|
|
$_POST['dstendport'] = $_POST['dstbeginport'];
|
236 |
|
|
$_POST['dstbeginport'] = $tmp;
|
237 |
|
|
}
|
238 |
e33c8694
|
Bill Marquette
|
if ($_POST['os'])
|
239 |
|
|
if( $_POST['proto'] != "tcp" )
|
240 |
|
|
$input_errors[] = "OS detection is only valid with protocol tcp.";
|
241 |
5b237745
|
Scott Ullrich
|
|
242 |
|
|
if (!$input_errors) {
|
243 |
|
|
$filterent = array();
|
244 |
|
|
$filterent['type'] = $_POST['type'];
|
245 |
|
|
$filterent['interface'] = $_POST['interface'];
|
246 |
d59874c1
|
Scott Ullrich
|
|
247 |
bdb7d6e7
|
Scott Ullrich
|
/* Advanced options */
|
248 |
|
|
$filterent['max-src-nodes'] = $_POST['max-src-nodes'];
|
249 |
|
|
$filterent['max-src-states'] = $_POST['max-src-states'];
|
250 |
5ba18897
|
Scott Ullrich
|
$filterent['statetimeout'] = $_POST['statetimeout'];
|
251 |
fa9af164
|
Scott Ullrich
|
$filterent['statetype'] = $_POST['statetype'];
|
252 |
e33c8694
|
Bill Marquette
|
$filterent['os'] = $_POST['os'];
|
253 |
f87f85c3
|
Bill Marquette
|
$filterent['max-src-conn-rate'] = $_POST['max-src-conn-rate'];
|
254 |
|
|
$filterent['max-src-conn-rates'] = $_POST['max-src-conn-rates'];
|
255 |
5ba18897
|
Scott Ullrich
|
|
256 |
5b237745
|
Scott Ullrich
|
if ($_POST['proto'] != "any")
|
257 |
|
|
$filterent['protocol'] = $_POST['proto'];
|
258 |
|
|
else
|
259 |
|
|
unset($filterent['protocol']);
|
260 |
5ba18897
|
Scott Ullrich
|
|
261 |
5b237745
|
Scott Ullrich
|
if ($_POST['proto'] == "icmp" && $_POST['icmptype'])
|
262 |
|
|
$filterent['icmptype'] = $_POST['icmptype'];
|
263 |
|
|
else
|
264 |
|
|
unset($filterent['icmptype']);
|
265 |
5ba18897
|
Scott Ullrich
|
|
266 |
5b237745
|
Scott Ullrich
|
pconfig_to_address($filterent['source'], $_POST['src'],
|
267 |
|
|
$_POST['srcmask'], $_POST['srcnot'],
|
268 |
|
|
$_POST['srcbeginport'], $_POST['srcendport']);
|
269 |
5ba18897
|
Scott Ullrich
|
|
270 |
5b237745
|
Scott Ullrich
|
pconfig_to_address($filterent['destination'], $_POST['dst'],
|
271 |
|
|
$_POST['dstmask'], $_POST['dstnot'],
|
272 |
|
|
$_POST['dstbeginport'], $_POST['dstendport']);
|
273 |
5ba18897
|
Scott Ullrich
|
|
274 |
f87f85c3
|
Bill Marquette
|
if ($_POST['disabled'])
|
275 |
|
|
$filterent['disabled'] = true;
|
276 |
|
|
else
|
277 |
|
|
unset($filterent['disabled']);
|
278 |
|
|
if ($_POST['log'])
|
279 |
|
|
$filterent['log'] = true;
|
280 |
|
|
else
|
281 |
|
|
unset($filterent['log']);
|
282 |
5b237745
|
Scott Ullrich
|
$filterent['descr'] = $_POST['descr'];
|
283 |
5ba18897
|
Scott Ullrich
|
|
284 |
5b237745
|
Scott Ullrich
|
if (isset($id) && $a_filter[$id])
|
285 |
|
|
$a_filter[$id] = $filterent;
|
286 |
|
|
else {
|
287 |
|
|
if (is_numeric($after))
|
288 |
|
|
array_splice($a_filter, $after+1, 0, array($filterent));
|
289 |
|
|
else
|
290 |
|
|
$a_filter[] = $filterent;
|
291 |
|
|
}
|
292 |
5ba18897
|
Scott Ullrich
|
|
293 |
5b237745
|
Scott Ullrich
|
write_config();
|
294 |
|
|
touch($d_filterconfdirty_path);
|
295 |
5ba18897
|
Scott Ullrich
|
|
296 |
a23d7248
|
Scott Ullrich
|
header("Location: firewall_rules.php?if=" . $_POST['interface']);
|
297 |
5b237745
|
Scott Ullrich
|
exit;
|
298 |
|
|
}
|
299 |
|
|
}
|
300 |
|
|
?>
|
301 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
302 |
|
|
<html>
|
303 |
|
|
<head>
|
304 |
|
|
<title><?=gentitle("Firewall: Rules: Edit");?></title>
|
305 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
306 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
307 |
|
|
<script language="JavaScript">
|
308 |
|
|
<!--
|
309 |
|
|
var portsenabled = 1;
|
310 |
bdb7d6e7
|
Scott Ullrich
|
|
311 |
5b237745
|
Scott Ullrich
|
function ext_change() {
|
312 |
|
|
if ((document.iform.srcbeginport.selectedIndex == 0) && portsenabled) {
|
313 |
|
|
document.iform.srcbeginport_cust.disabled = 0;
|
314 |
|
|
} else {
|
315 |
|
|
document.iform.srcbeginport_cust.value = "";
|
316 |
|
|
document.iform.srcbeginport_cust.disabled = 1;
|
317 |
|
|
}
|
318 |
|
|
if ((document.iform.srcendport.selectedIndex == 0) && portsenabled) {
|
319 |
|
|
document.iform.srcendport_cust.disabled = 0;
|
320 |
|
|
} else {
|
321 |
|
|
document.iform.srcendport_cust.value = "";
|
322 |
|
|
document.iform.srcendport_cust.disabled = 1;
|
323 |
|
|
}
|
324 |
|
|
if ((document.iform.dstbeginport.selectedIndex == 0) && portsenabled) {
|
325 |
|
|
document.iform.dstbeginport_cust.disabled = 0;
|
326 |
|
|
} else {
|
327 |
|
|
document.iform.dstbeginport_cust.value = "";
|
328 |
|
|
document.iform.dstbeginport_cust.disabled = 1;
|
329 |
|
|
}
|
330 |
|
|
if ((document.iform.dstendport.selectedIndex == 0) && portsenabled) {
|
331 |
|
|
document.iform.dstendport_cust.disabled = 0;
|
332 |
|
|
} else {
|
333 |
|
|
document.iform.dstendport_cust.value = "";
|
334 |
|
|
document.iform.dstendport_cust.disabled = 1;
|
335 |
|
|
}
|
336 |
5ba18897
|
Scott Ullrich
|
|
337 |
5b237745
|
Scott Ullrich
|
if (!portsenabled) {
|
338 |
|
|
document.iform.srcbeginport.disabled = 1;
|
339 |
|
|
document.iform.srcendport.disabled = 1;
|
340 |
|
|
document.iform.dstbeginport.disabled = 1;
|
341 |
|
|
document.iform.dstendport.disabled = 1;
|
342 |
|
|
} else {
|
343 |
|
|
document.iform.srcbeginport.disabled = 0;
|
344 |
|
|
document.iform.srcendport.disabled = 0;
|
345 |
|
|
document.iform.dstbeginport.disabled = 0;
|
346 |
|
|
document.iform.dstendport.disabled = 0;
|
347 |
|
|
}
|
348 |
|
|
}
|
349 |
|
|
|
350 |
bdb7d6e7
|
Scott Ullrich
|
function typesel_change() {
|
351 |
5b237745
|
Scott Ullrich
|
switch (document.iform.srctype.selectedIndex) {
|
352 |
|
|
case 1: /* single */
|
353 |
|
|
document.iform.src.disabled = 0;
|
354 |
|
|
document.iform.srcmask.value = "";
|
355 |
|
|
document.iform.srcmask.disabled = 1;
|
356 |
|
|
break;
|
357 |
|
|
case 2: /* network */
|
358 |
|
|
document.iform.src.disabled = 0;
|
359 |
|
|
document.iform.srcmask.disabled = 0;
|
360 |
|
|
break;
|
361 |
|
|
default:
|
362 |
|
|
document.iform.src.value = "";
|
363 |
|
|
document.iform.src.disabled = 1;
|
364 |
|
|
document.iform.srcmask.value = "";
|
365 |
|
|
document.iform.srcmask.disabled = 1;
|
366 |
|
|
break;
|
367 |
|
|
}
|
368 |
|
|
switch (document.iform.dsttype.selectedIndex) {
|
369 |
|
|
case 1: /* single */
|
370 |
|
|
document.iform.dst.disabled = 0;
|
371 |
|
|
document.iform.dstmask.value = "";
|
372 |
|
|
document.iform.dstmask.disabled = 1;
|
373 |
|
|
break;
|
374 |
|
|
case 2: /* network */
|
375 |
|
|
document.iform.dst.disabled = 0;
|
376 |
|
|
document.iform.dstmask.disabled = 0;
|
377 |
|
|
break;
|
378 |
|
|
default:
|
379 |
|
|
document.iform.dst.value = "";
|
380 |
|
|
document.iform.dst.disabled = 1;
|
381 |
|
|
document.iform.dstmask.value = "";
|
382 |
|
|
document.iform.dstmask.disabled = 1;
|
383 |
|
|
break;
|
384 |
|
|
}
|
385 |
|
|
}
|
386 |
|
|
|
387 |
|
|
function proto_change() {
|
388 |
|
|
if (document.iform.proto.selectedIndex < 3) {
|
389 |
|
|
portsenabled = 1;
|
390 |
|
|
} else {
|
391 |
|
|
portsenabled = 0;
|
392 |
|
|
}
|
393 |
5ba18897
|
Scott Ullrich
|
|
394 |
65465a3c
|
Scott Ullrich
|
/* Disable OS knob if the proto is not TCP. */
|
395 |
|
|
if (document.iform.proto.selectedIndex < 1) {
|
396 |
|
|
document.forms[0].os.disabled = 0;
|
397 |
|
|
} else {
|
398 |
|
|
document.forms[0].os.disabled = 1;
|
399 |
|
|
}
|
400 |
|
|
|
401 |
5b237745
|
Scott Ullrich
|
if (document.iform.proto.selectedIndex == 3) {
|
402 |
|
|
document.iform.icmptype.disabled = 0;
|
403 |
|
|
} else {
|
404 |
|
|
document.iform.icmptype.disabled = 1;
|
405 |
|
|
}
|
406 |
5ba18897
|
Scott Ullrich
|
|
407 |
5b237745
|
Scott Ullrich
|
ext_change();
|
408 |
|
|
}
|
409 |
|
|
|
410 |
|
|
function src_rep_change() {
|
411 |
|
|
document.iform.srcendport.selectedIndex = document.iform.srcbeginport.selectedIndex;
|
412 |
|
|
}
|
413 |
|
|
function dst_rep_change() {
|
414 |
|
|
document.iform.dstendport.selectedIndex = document.iform.dstbeginport.selectedIndex;
|
415 |
|
|
}
|
416 |
|
|
//-->
|
417 |
|
|
</script>
|
418 |
|
|
</head>
|
419 |
|
|
|
420 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
421 |
|
|
<?php include("fbegin.inc"); ?>
|
422 |
|
|
<p class="pgtitle">Firewall: Rules: Edit</p>
|
423 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
424 |
|
|
<form action="firewall_rules_edit.php" method="post" name="iform" id="iform">
|
425 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
426 |
5ba18897
|
Scott Ullrich
|
<tr>
|
427 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Action</td>
|
428 |
|
|
<td width="78%" class="vtable">
|
429 |
bdb7d6e7
|
Scott Ullrich
|
<select name="type" class="formfld">
|
430 |
5b237745
|
Scott Ullrich
|
<?php $types = explode(" ", "Pass Block Reject"); foreach ($types as $type): ?>
|
431 |
|
|
<option value="<?=strtolower($type);?>" <?php if (strtolower($type) == strtolower($pconfig['type'])) echo "selected"; ?>>
|
432 |
|
|
<?=htmlspecialchars($type);?>
|
433 |
|
|
</option>
|
434 |
|
|
<?php endforeach; ?>
|
435 |
|
|
</select> <br>
|
436 |
bdb7d6e7
|
Scott Ullrich
|
<span class="vexpl">Choose what to do with packets that match
|
437 |
|
|
the criteria specified below.<br>
|
438 |
|
|
Hint: the difference between block and reject is that with reject, a packet (TCP RST or ICMP port unreachable for UDP) is returned to the sender, whereas with block the packet is dropped silently. In either case, the original packet is discarded. Reject only works when the protocol is set to either TCP or UDP (but not "TCP/UDP") below.</span></td>
|
439 |
5b237745
|
Scott Ullrich
|
</tr>
|
440 |
5ba18897
|
Scott Ullrich
|
<tr>
|
441 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Disabled</td>
|
442 |
5ba18897
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
443 |
5b237745
|
Scott Ullrich
|
<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
|
444 |
|
|
<strong>Disable this rule</strong><br>
|
445 |
|
|
<span class="vexpl">Set this option to disable this rule without
|
446 |
|
|
removing it from the list.</span></td>
|
447 |
|
|
</tr>
|
448 |
5ba18897
|
Scott Ullrich
|
<tr>
|
449 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Interface</td>
|
450 |
|
|
<td width="78%" class="vtable">
|
451 |
bdb7d6e7
|
Scott Ullrich
|
<select name="interface" class="formfld">
|
452 |
5b237745
|
Scott Ullrich
|
<?php $interfaces = array('wan' => 'WAN', 'lan' => 'LAN', 'pptp' => 'PPTP');
|
453 |
|
|
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
|
454 |
|
|
$interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
|
455 |
|
|
}
|
456 |
|
|
foreach ($interfaces as $iface => $ifacename): ?>
|
457 |
|
|
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
|
458 |
|
|
<?=htmlspecialchars($ifacename);?>
|
459 |
|
|
</option>
|
460 |
|
|
<?php endforeach; ?>
|
461 |
|
|
</select> <br>
|
462 |
5ba18897
|
Scott Ullrich
|
<span class="vexpl">Choose on which interface packets must
|
463 |
5b237745
|
Scott Ullrich
|
come in to match this rule.</span></td>
|
464 |
|
|
</tr>
|
465 |
5ba18897
|
Scott Ullrich
|
<tr>
|
466 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Protocol</td>
|
467 |
|
|
<td width="78%" class="vtable">
|
468 |
bdb7d6e7
|
Scott Ullrich
|
<select name="proto" class="formfld" onchange="proto_change()">
|
469 |
9620d290
|
Scott Ullrich
|
<?php $protocols = explode(" ", "TCP UDP TCP/UDP ICMP ICMP6 ESP AH GRE IPv6 IGMP any carp pfsync"); foreach ($protocols as $proto): ?>
|
470 |
5b237745
|
Scott Ullrich
|
<option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>>
|
471 |
|
|
<?=htmlspecialchars($proto);?>
|
472 |
|
|
</option>
|
473 |
|
|
<?php endforeach; ?>
|
474 |
|
|
</select> <br>
|
475 |
5ba18897
|
Scott Ullrich
|
<span class="vexpl">Choose which IP protocol this rule should
|
476 |
5b237745
|
Scott Ullrich
|
match.<br>
|
477 |
|
|
Hint: in most cases, you should specify <em>TCP</em> here.</span></td>
|
478 |
|
|
</tr>
|
479 |
|
|
<tr>
|
480 |
|
|
<td valign="top" class="vncell">ICMP type</td>
|
481 |
|
|
<td class="vtable">
|
482 |
|
|
<select name="icmptype" class="formfld">
|
483 |
|
|
<?php
|
484 |
5ba18897
|
Scott Ullrich
|
|
485 |
5b237745
|
Scott Ullrich
|
$icmptypes = array(
|
486 |
|
|
"" => "any",
|
487 |
|
|
"echorep" => "Echo reply",
|
488 |
ec4940b9
|
Bill Marquette
|
"unreach" => "Destination unreachable",
|
489 |
5b237745
|
Scott Ullrich
|
"squench" => "Source quench",
|
490 |
|
|
"redir" => "Redirect",
|
491 |
ec4940b9
|
Bill Marquette
|
"althost" => "Alternate Host",
|
492 |
|
|
"echoreq" => "Echo",
|
493 |
|
|
"routeradv" => "Router advertisement",
|
494 |
|
|
"routersol" => "Router solicitation",
|
495 |
5b237745
|
Scott Ullrich
|
"timex" => "Time exceeded",
|
496 |
ec4940b9
|
Bill Marquette
|
"paramprob" => "Invalid IP header",
|
497 |
|
|
"timereq" => "Timestamp",
|
498 |
|
|
"timerep" => "Timestamp reply",
|
499 |
5b237745
|
Scott Ullrich
|
"inforeq" => "Information request",
|
500 |
|
|
"inforep" => "Information reply",
|
501 |
|
|
"maskreq" => "Address mask request",
|
502 |
|
|
"maskrep" => "Address mask reply"
|
503 |
|
|
);
|
504 |
5ba18897
|
Scott Ullrich
|
|
505 |
5b237745
|
Scott Ullrich
|
foreach ($icmptypes as $icmptype => $descr): ?>
|
506 |
|
|
<option value="<?=$icmptype;?>" <?php if ($icmptype == $pconfig['icmptype']) echo "selected"; ?>>
|
507 |
|
|
<?=htmlspecialchars($descr);?>
|
508 |
|
|
</option>
|
509 |
|
|
<?php endforeach; ?>
|
510 |
|
|
</select>
|
511 |
|
|
<br>
|
512 |
|
|
<span class="vexpl">If you selected ICMP for the protocol above, you may specify an ICMP type here.</span></td>
|
513 |
|
|
</tr>
|
514 |
5ba18897
|
Scott Ullrich
|
<tr>
|
515 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Source</td>
|
516 |
|
|
<td width="78%" class="vtable">
|
517 |
bdb7d6e7
|
Scott Ullrich
|
<input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
|
518 |
5b237745
|
Scott Ullrich
|
<strong>not</strong><br>
|
519 |
|
|
Use this option to invert the sense of the match.<br>
|
520 |
|
|
<br>
|
521 |
|
|
<table border="0" cellspacing="0" cellpadding="0">
|
522 |
5ba18897
|
Scott Ullrich
|
<tr>
|
523 |
5b237745
|
Scott Ullrich
|
<td>Type: </td>
|
524 |
bdb7d6e7
|
Scott Ullrich
|
<td><select name="srctype" class="formfld" onChange="typesel_change()">
|
525 |
5b237745
|
Scott Ullrich
|
<?php $sel = is_specialnet($pconfig['src']); ?>
|
526 |
|
|
<option value="any" <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>>
|
527 |
|
|
any</option>
|
528 |
|
|
<option value="single" <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
|
529 |
|
|
Single host or alias</option>
|
530 |
|
|
<option value="network" <?php if (!$sel) echo "selected"; ?>>
|
531 |
|
|
Network</option>
|
532 |
|
|
<option value="lan" <?php if ($pconfig['src'] == "lan") { echo "selected"; } ?>>
|
533 |
|
|
LAN subnet</option>
|
534 |
|
|
<option value="pptp" <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>>
|
535 |
|
|
PPTP clients</option>
|
536 |
|
|
<?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
|
537 |
|
|
<option value="opt<?=$i;?>" <?php if ($pconfig['src'] == "opt" . $i) { echo "selected"; } ?>>
|
538 |
|
|
<?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?> subnet</option>
|
539 |
|
|
<?php endfor; ?>
|
540 |
|
|
</select></td>
|
541 |
|
|
</tr>
|
542 |
5ba18897
|
Scott Ullrich
|
<tr>
|
543 |
5b237745
|
Scott Ullrich
|
<td>Address: </td>
|
544 |
3d85f6b4
|
Scott Ullrich
|
<td><input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this)' onkeyup='actb_tocomplete(this,event,addressarray);' name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>">
|
545 |
5b237745
|
Scott Ullrich
|
/
|
546 |
bdb7d6e7
|
Scott Ullrich
|
<select name="srcmask" class="formfld" id="srcmask">
|
547 |
|
|
<?php for ($i = 31; $i > 0; $i--): ?>
|
548 |
|
|
<option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>><?=$i;?></option>
|
549 |
|
|
<?php endfor; ?>
|
550 |
|
|
</select>
|
551 |
|
|
</td>
|
552 |
|
|
</tr>
|
553 |
5b237745
|
Scott Ullrich
|
</table></td>
|
554 |
|
|
</tr>
|
555 |
5ba18897
|
Scott Ullrich
|
<tr>
|
556 |
|
|
<td width="22%" valign="top" class="vncellreq">Source port range
|
557 |
5b237745
|
Scott Ullrich
|
</td>
|
558 |
5ba18897
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
559 |
5b237745
|
Scott Ullrich
|
<table border="0" cellspacing="0" cellpadding="0">
|
560 |
5ba18897
|
Scott Ullrich
|
<tr>
|
561 |
5b237745
|
Scott Ullrich
|
<td>from: </td>
|
562 |
|
|
<td><select name="srcbeginport" class="formfld" onchange="src_rep_change();ext_change()">
|
563 |
|
|
<option value="">(other)</option>
|
564 |
bdb7d6e7
|
Scott Ullrich
|
<option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
|
565 |
5b237745
|
Scott Ullrich
|
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
|
566 |
|
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) {
|
567 |
|
|
echo "selected";
|
568 |
|
|
$bfound = 1;
|
569 |
|
|
}?>>
|
570 |
|
|
<?=htmlspecialchars($wkportdesc);?>
|
571 |
|
|
</option>
|
572 |
|
|
<?php endforeach; ?>
|
573 |
3d85f6b4
|
Scott Ullrich
|
</select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo $pconfig['srcbeginport']; ?>"></td>
|
574 |
5b237745
|
Scott Ullrich
|
</tr>
|
575 |
5ba18897
|
Scott Ullrich
|
<tr>
|
576 |
5b237745
|
Scott Ullrich
|
<td>to:</td>
|
577 |
|
|
<td><select name="srcendport" class="formfld" onchange="ext_change()">
|
578 |
|
|
<option value="">(other)</option>
|
579 |
bdb7d6e7
|
Scott Ullrich
|
<option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
|
580 |
5b237745
|
Scott Ullrich
|
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
|
581 |
|
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) {
|
582 |
|
|
echo "selected";
|
583 |
|
|
$bfound = 1;
|
584 |
|
|
}?>>
|
585 |
|
|
<?=htmlspecialchars($wkportdesc);?>
|
586 |
|
|
</option>
|
587 |
|
|
<?php endforeach; ?>
|
588 |
3d85f6b4
|
Scott Ullrich
|
</select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>"></td>
|
589 |
5b237745
|
Scott Ullrich
|
</tr>
|
590 |
|
|
</table>
|
591 |
5ba18897
|
Scott Ullrich
|
<br>
|
592 |
|
|
<span class="vexpl">Specify the port or port range for
|
593 |
bdb7d6e7
|
Scott Ullrich
|
the source of the packet for this rule. This is usually not equal to the destination port range (and is often "any"). <br>
|
594 |
5ba18897
|
Scott Ullrich
|
Hint: you can leave the <em>'to'</em> field empty if you only
|
595 |
5b237745
|
Scott Ullrich
|
want to filter a single port</span></td>
|
596 |
e33c8694
|
Bill Marquette
|
|
597 |
|
|
<tr>
|
598 |
|
|
<td width="22%" valign="top" class="vncellreq">Source OS</td>
|
599 |
|
|
<td width="78%" class="vtable">OS Type:
|
600 |
65465a3c
|
Scott Ullrich
|
<select name="os" id="os" class="formfld">
|
601 |
e33c8694
|
Bill Marquette
|
<?php
|
602 |
|
|
$ostypes = array(
|
603 |
|
|
"" => "any",
|
604 |
|
|
"AIX" => "AIX",
|
605 |
|
|
"Linux" => "Linux",
|
606 |
|
|
"FreeBSD" => "FreeBSD",
|
607 |
|
|
"NetBSD" => "NetBSD",
|
608 |
|
|
"OpenBSD" => "OpenBSD",
|
609 |
|
|
"Solaris" => "Solaris",
|
610 |
|
|
"MacOS" => "MacOS",
|
611 |
|
|
"Windows" => "Windows",
|
612 |
|
|
"Novell" => "Novell"
|
613 |
|
|
);
|
614 |
|
|
|
615 |
|
|
foreach ($ostypes as $ostype => $descr): ?>
|
616 |
|
|
<option value="<?=$ostype;?>" <?php if ($ostype == $pconfig['os']) echo "selected"; ?>>
|
617 |
|
|
<?=htmlspecialchars($descr);?>
|
618 |
|
|
</option>
|
619 |
|
|
<?php endforeach; ?>
|
620 |
|
|
</select><br>
|
621 |
|
|
Note: this only works for TCP rules</td>
|
622 |
|
|
</tr>
|
623 |
5ba18897
|
Scott Ullrich
|
<tr>
|
624 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Destination</td>
|
625 |
5ba18897
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
626 |
|
|
<input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
|
627 |
5b237745
|
Scott Ullrich
|
<strong>not</strong><br>
|
628 |
|
|
Use this option to invert the sense of the match.<br>
|
629 |
|
|
<br>
|
630 |
|
|
<table border="0" cellspacing="0" cellpadding="0">
|
631 |
5ba18897
|
Scott Ullrich
|
<tr>
|
632 |
5b237745
|
Scott Ullrich
|
<td>Type: </td>
|
633 |
bdb7d6e7
|
Scott Ullrich
|
<td><select name="dsttype" class="formfld" onChange="typesel_change()">
|
634 |
5b237745
|
Scott Ullrich
|
<?php $sel = is_specialnet($pconfig['dst']); ?>
|
635 |
|
|
<option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>>
|
636 |
|
|
any</option>
|
637 |
|
|
<option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
|
638 |
|
|
Single host or alias</option>
|
639 |
|
|
<option value="network" <?php if (!$sel) echo "selected"; ?>>
|
640 |
|
|
Network</option>
|
641 |
|
|
<option value="lan" <?php if ($pconfig['dst'] == "lan") { echo "selected"; } ?>>
|
642 |
|
|
LAN subnet</option>
|
643 |
|
|
<option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>>
|
644 |
|
|
PPTP clients</option>
|
645 |
|
|
<?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): ?>
|
646 |
|
|
<option value="opt<?=$i;?>" <?php if ($pconfig['dst'] == "opt" . $i) { echo "selected"; } ?>>
|
647 |
|
|
<?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?> subnet</option>
|
648 |
|
|
<?php endfor; ?>
|
649 |
|
|
</select></td>
|
650 |
|
|
</tr>
|
651 |
5ba18897
|
Scott Ullrich
|
<tr>
|
652 |
5b237745
|
Scott Ullrich
|
<td>Address: </td>
|
653 |
3d85f6b4
|
Scott Ullrich
|
<td><input name="dst" autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,addressarray)' type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
|
654 |
5ba18897
|
Scott Ullrich
|
/
|
655 |
bdb7d6e7
|
Scott Ullrich
|
<select name="dstmask" class="formfld" id="dstmask">
|
656 |
|
|
<?php for ($i = 31; $i > 0; $i--): ?>
|
657 |
|
|
<option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>><?=$i;?></option>
|
658 |
|
|
<?php endfor; ?>
|
659 |
|
|
</select></td>
|
660 |
5b237745
|
Scott Ullrich
|
</tr>
|
661 |
|
|
</table></td>
|
662 |
|
|
</tr>
|
663 |
5ba18897
|
Scott Ullrich
|
<tr>
|
664 |
|
|
<td width="22%" valign="top" class="vncellreq">Destination port
|
665 |
5b237745
|
Scott Ullrich
|
range </td>
|
666 |
5ba18897
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
667 |
5b237745
|
Scott Ullrich
|
<table border="0" cellspacing="0" cellpadding="0">
|
668 |
5ba18897
|
Scott Ullrich
|
<tr>
|
669 |
5b237745
|
Scott Ullrich
|
<td>from: </td>
|
670 |
|
|
<td><select name="dstbeginport" class="formfld" onchange="dst_rep_change();ext_change()">
|
671 |
|
|
<option value="">(other)</option>
|
672 |
|
|
<option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
|
673 |
|
|
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
|
674 |
|
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) {
|
675 |
|
|
echo "selected";
|
676 |
|
|
$bfound = 1;
|
677 |
|
|
}?>>
|
678 |
|
|
<?=htmlspecialchars($wkportdesc);?>
|
679 |
|
|
</option>
|
680 |
|
|
<?php endforeach; ?>
|
681 |
3d85f6b4
|
Scott Ullrich
|
</select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo $pconfig['dstbeginport']; ?>"></td>
|
682 |
5b237745
|
Scott Ullrich
|
</tr>
|
683 |
5ba18897
|
Scott Ullrich
|
<tr>
|
684 |
5b237745
|
Scott Ullrich
|
<td>to:</td>
|
685 |
|
|
<td><select name="dstendport" class="formfld" onchange="ext_change()">
|
686 |
|
|
<option value="">(other)</option>
|
687 |
|
|
<option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
|
688 |
|
|
<?php foreach ($wkports as $wkport => $wkportdesc): ?>
|
689 |
|
|
<option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) {
|
690 |
|
|
echo "selected";
|
691 |
|
|
$bfound = 1;
|
692 |
|
|
}?>>
|
693 |
|
|
<?=htmlspecialchars($wkportdesc);?>
|
694 |
|
|
</option>
|
695 |
|
|
<?php endforeach; ?>
|
696 |
3d85f6b4
|
Scott Ullrich
|
</select> <input autocomplete='off' onblur='actb_removedisp()' onkeypress='return (event.keyCode!=13);' onkeydown='actb_checkkey(event, this);' onkeyup='actb_tocomplete(this,event,customarray)' class="formfldalias" name="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo $pconfig['dstendport']; ?>"></td>
|
697 |
5b237745
|
Scott Ullrich
|
</tr>
|
698 |
|
|
</table>
|
699 |
5ba18897
|
Scott Ullrich
|
<br> <span class="vexpl">Specify the port or port range for
|
700 |
5b237745
|
Scott Ullrich
|
the destination of the packet for this rule.<br>
|
701 |
5ba18897
|
Scott Ullrich
|
Hint: you can leave the <em>'to'</em> field empty if you only
|
702 |
5b237745
|
Scott Ullrich
|
want to filter a single port</span></td>
|
703 |
bdb7d6e7
|
Scott Ullrich
|
</tr>
|
704 |
5ba18897
|
Scott Ullrich
|
<tr>
|
705 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Log</td>
|
706 |
5ba18897
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
707 |
5b237745
|
Scott Ullrich
|
<input name="log" type="checkbox" id="log" value="yes" <?php if ($pconfig['log']) echo "checked"; ?>>
|
708 |
|
|
<strong>Log packets that are handled by this rule</strong><br>
|
709 |
5ba18897
|
Scott Ullrich
|
<span class="vexpl">Hint: the firewall has limited local log
|
710 |
|
|
space. Don't turn on logging for everything. If you want to
|
711 |
|
|
do a lot of logging, consider using a remote syslog server
|
712 |
|
|
(see the <a href="diag_logs_settings.php">Diagnostics: System
|
713 |
5b237745
|
Scott Ullrich
|
logs: Settings</a> page).</span></td>
|
714 |
|
|
</tr>
|
715 |
5ba18897
|
Scott Ullrich
|
<tr>
|
716 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncell">Description</td>
|
717 |
5ba18897
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
718 |
|
|
<input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
719 |
|
|
<br> <span class="vexpl">You may enter a description here
|
720 |
5b237745
|
Scott Ullrich
|
for your reference (not parsed).</span></td>
|
721 |
|
|
</tr>
|
722 |
a44455c4
|
Scott Ullrich
|
<tr>
|
723 |
|
|
<td width="22%" valign="top" class="vncell">Advanced Options</td>
|
724 |
|
|
<td width="78%" class="vtable">
|
725 |
|
|
<input name="max-src-nodes" id="max-src-nodes" value="<?php echo $pconfig['max-src-nodes'] ?>"><br> Simultaneous client connection limit<p>
|
726 |
e33c8694
|
Bill Marquette
|
<input name="max-src-states" id="max-src-states" value="<?php echo $pconfig['max-src-states'] ?>"><br> Maximum state entries per host<p>
|
727 |
ed08ef3e
|
Scott Ullrich
|
<input name="max-src-conn-rate" id="max-src-conn-rate" value="<?php echo $pconfig['max-src-conn-rate'] ?>"> /
|
728 |
|
|
<select name="max-src-conn-rates" id="max-src-conn-rates">
|
729 |
40b0fe5b
|
Scott Ullrich
|
<option value=""<?php if(intval($pconfig['max-src-conn-rates']) < 1) echo " selected"; ?>></option>
|
730 |
ed08ef3e
|
Scott Ullrich
|
<?php
|
731 |
40b0fe5b
|
Scott Ullrich
|
for($x=1; $x<255; $x++) {
|
732 |
ed08ef3e
|
Scott Ullrich
|
if($x == $pconfig['max-src-conn-rates'])
|
733 |
|
|
$selected = " selected";
|
734 |
|
|
else
|
735 |
|
|
$selected = "";
|
736 |
|
|
echo "<option value=\"{$x}\"{$selected}>{$x}</option>\n";
|
737 |
|
|
}
|
738 |
|
|
?>
|
739 |
|
|
</select>
|
740 |
|
|
<br>
|
741 |
40b0fe5b
|
Scott Ullrich
|
Maximum new connections / per second
|
742 |
4cc0d94c
|
Scott Ullrich
|
<p><strong>NOTE: Leave these fields blank to disable this feature.</strong>
|
743 |
a44455c4
|
Scott Ullrich
|
</td>
|
744 |
|
|
</tr>
|
745 |
3849b323
|
Scott Ullrich
|
<tr>
|
746 |
|
|
<td width="22%" valign="top" class="vncell">State Type</td>
|
747 |
|
|
<td width="78%" class="vtable">
|
748 |
d59874c1
|
Scott Ullrich
|
<select name="statetype">
|
749 |
3849b323
|
Scott Ullrich
|
<option value="keep state" <?php if(!isset($pconfig['statetype']) or $pconfig['statetype'] == "keep state") echo "selected"; ?>>keep state</option>
|
750 |
|
|
<option value="modulate state" <?php if($pconfig['statetype'] == "modulate state") echo "selected"; ?>>modulate state</option>
|
751 |
|
|
<option value="synproxy state"<?php if($pconfig['statetype'] == "synproxy state") echo "selected"; ?>>synproxy state</option>
|
752 |
|
|
<option value="none"<?php if($pconfig['statetype'] == "none") echo "selected"; ?>>none</option>
|
753 |
|
|
</select><br>HINT: Select which type of state tracking mechanism you would like to use. If in doubt, use keep state.
|
754 |
|
|
<p><strong>
|
755 |
|
|
<table>
|
756 |
5ba18897
|
Scott Ullrich
|
<tr><td width="25%"><li>keep state</li></td><td>works with TCP, UDP, and ICMP.</td></tr>
|
757 |
|
|
<tr><td width="25%"><li>modulate state</li></td><td>works only with TCP. pfSense will generate strong Initial Sequence Numbers (ISNs) for packets matching this rule.</li></td></tr>
|
758 |
|
|
<tr><td width="25%"><li>synproxy state</li></td><td>proxies incoming TCP connections to help protect servers from spoofed TCP SYN floods. This option includes the functionality of keep state and modulate state combined.</td></tr>
|
759 |
|
|
<tr><td width="25%"><li>none</li></td><td>do not use state mechanisms to keep track. this is only useful if your doing advanced queueing in certain situations. please check the faq.</td></tr>
|
760 |
|
|
</table>
|
761 |
3849b323
|
Scott Ullrich
|
</strong>
|
762 |
|
|
</td>
|
763 |
|
|
</tr>
|
764 |
a44455c4
|
Scott Ullrich
|
|
765 |
5ba18897
|
Scott Ullrich
|
<tr>
|
766 |
|
|
<td width="22%" valign="top" class="vncell">State Timeout</td>
|
767 |
|
|
<td width="78%" class="vtable">
|
768 |
|
|
<input name="statetimeout" value="<?php echo $pconfig['frags'] ?>">
|
769 |
|
|
<p><strong>Leave blank for default. Amount is in seconds.
|
770 |
|
|
</strong>
|
771 |
|
|
</td>
|
772 |
|
|
</tr>
|
773 |
|
|
|
774 |
82628210
|
Scott Ullrich
|
<?php
|
775 |
|
|
/* build a list of gateways */
|
776 |
|
|
$gateways = array();
|
777 |
fe038cb6
|
Bill Marquette
|
exec("/sbin/route -n get default |/usr/bin/grep gateway", $defroute);
|
778 |
|
|
preg_match("/(\d+\.\d+\.\d+\.\d+)/", $defroute[0], $matches);
|
779 |
|
|
$gateways[] = $matches[1];
|
780 |
82628210
|
Scott Ullrich
|
foreach($config['interfaces'] as $int) {
|
781 |
|
|
if($int['gateway'] <> "")
|
782 |
|
|
$gateways[]=$int['gateway'];
|
783 |
|
|
}
|
784 |
|
|
?>
|
785 |
|
|
<tr>
|
786 |
|
|
<td width="22%" valign="top" class="vncell">Gateway</td>
|
787 |
|
|
<td width="78%" class="vtable">
|
788 |
|
|
<select name='gateway'>
|
789 |
|
|
<?php
|
790 |
|
|
foreach($gateways as $gw) {
|
791 |
dd31e6a9
|
Scott Ullrich
|
if($gw == $pconfig['gateway'])
|
792 |
82628210
|
Scott Ullrich
|
$selected = " SELECTED";
|
793 |
|
|
else
|
794 |
|
|
$selected = "";
|
795 |
|
|
if($gw <> "")
|
796 |
|
|
echo "<option value=\"{$gw}\" {$selected}>{$gw}</option>\n";
|
797 |
|
|
}
|
798 |
|
|
?>
|
799 |
|
|
</select>
|
800 |
|
|
<p><strong>Leave blank for default.
|
801 |
|
|
</strong>
|
802 |
|
|
</td>
|
803 |
|
|
</tr>
|
804 |
5ba18897
|
Scott Ullrich
|
<tr>
|
805 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
806 |
5ba18897
|
Scott Ullrich
|
<td width="78%">
|
807 |
fc01e414
|
Scott Ullrich
|
<input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" class="formbtn" value="Cancel" onclick="history.back()">
|
808 |
5b237745
|
Scott Ullrich
|
<?php if (isset($id) && $a_filter[$id]): ?>
|
809 |
5ba18897
|
Scott Ullrich
|
<input name="id" type="hidden" value="<?=$id;?>">
|
810 |
5b237745
|
Scott Ullrich
|
<?php endif; ?>
|
811 |
5ba18897
|
Scott Ullrich
|
<input name="after" type="hidden" value="<?=$after;?>">
|
812 |
5b237745
|
Scott Ullrich
|
</td>
|
813 |
|
|
</tr>
|
814 |
|
|
</table>
|
815 |
|
|
</form>
|
816 |
|
|
<script language="JavaScript">
|
817 |
|
|
<!--
|
818 |
|
|
ext_change();
|
819 |
|
|
typesel_change();
|
820 |
|
|
proto_change();
|
821 |
19757279
|
Scott Ullrich
|
|
822 |
|
|
<?php
|
823 |
|
|
$isfirst = 0;
|
824 |
|
|
$aliases = "";
|
825 |
|
|
$addrisfirst = 0;
|
826 |
|
|
$aliasesaddr = "";
|
827 |
092ac49d
|
Scott Ullrich
|
if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
|
828 |
|
|
foreach($config['aliases']['alias'] as $alias_name) {
|
829 |
|
|
if(!stristr($alias_name['address'], ".")) {
|
830 |
|
|
if($isfirst == 1) $aliases .= ",";
|
831 |
|
|
$aliases .= "'" . $alias_name['name'] . "'";
|
832 |
|
|
$isfirst = 1;
|
833 |
|
|
} else {
|
834 |
|
|
if($addrisfirst == 1) $aliasesaddr .= ",";
|
835 |
|
|
$aliasesaddr .= "'" . $alias_name['name'] . "'";
|
836 |
|
|
$addrisfirst = 1;
|
837 |
|
|
}
|
838 |
19757279
|
Scott Ullrich
|
}
|
839 |
|
|
?>
|
840 |
|
|
|
841 |
|
|
var addressarray=new Array(<?php echo $aliasesaddr; ?>);
|
842 |
|
|
var customarray=new Array(<?php echo $aliases; ?>);
|
843 |
|
|
|
844 |
5b237745
|
Scott Ullrich
|
//-->
|
845 |
|
|
</script>
|
846 |
ef8b343d
|
Scott Ullrich
|
<script type="text/javascript" language="javascript" src="auto_complete_helper.js">
|
847 |
|
|
</script>
|
848 |
5b237745
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
849 |
|
|
</body>
|
850 |
|
|
</html>
|