Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
7bc5bf4d
Commit
7bc5bf4d
authored
Oct 31, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(filter) move some more static rules
parent
5319b8e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
27 deletions
+20
-27
filter.inc
src/etc/inc/filter.inc
+0
-26
filter.lib.inc
src/etc/inc/filter.lib.inc
+15
-0
FilterRule.php
...opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php
+5
-1
No files found.
src/etc/inc/filter.inc
View file @
7bc5bf4d
...
...
@@ -2502,19 +2502,6 @@ function filter_rules_generate(&$FilterIflist)
$log
[
'block'
]
=
!
isset
(
$config
[
'syslog'
][
'nologdefaultblock'
])
?
"log"
:
""
;
$log
[
'pass'
]
=
!
isset
(
$config
[
'syslog'
][
'nologdefaultpass'
])
?
"log"
:
""
;
$ipfrules
.=
<<<EOD
# We use the mighty pf, we cannot be fooled.
block {$log['block']} quick inet proto { tcp, udp } from any port = 0 to any
block {$log['block']} quick inet proto { tcp, udp } from any to any port = 0
block {$log['block']} quick inet6 proto { tcp, udp } from any port = 0 to any
block {$log['block']} quick inet6 proto { tcp, udp } from any to any port = 0
EOD;
$ipfrules
.=
filter_process_carp_rules
(
$log
);
$ipfrules
.=
"
\n
# SSH lockout
\n
"
;
if
(
!
empty
(
$config
[
'system'
][
'ssh'
][
'port'
]))
{
$ipfrules
.=
"block in
{
$log
[
'block'
]
}
quick proto tcp from <sshlockout> to (self) port "
;
...
...
@@ -3111,19 +3098,6 @@ function filter_setup_logging_interfaces(&$FilterIflist)
return
$rules
;
}
function
filter_process_carp_rules
(
$log
)
{
global
$config
;
$lines
=
''
;
/* return if there are no carp configured items */
if
(
!
empty
(
$config
[
'hasync'
])
||
!
empty
(
$config
[
'virtualip'
][
'vip'
]))
{
$lines
.=
"block in
{
$log
[
'block'
]
}
quick proto carp from (self) to any
\n
"
;
$lines
.=
"pass
{
$log
[
'pass'
]
}
quick proto carp
\n
"
;
}
return
$lines
;
}
/* Generate IPsec Filter Items */
function
filter_generate_ipsec_rules
(
&
$FilterIflist
,
$log
=
array
())
{
...
...
src/etc/inc/filter.lib.inc
View file @
7bc5bf4d
...
...
@@ -88,5 +88,20 @@ function filter_core_rules_system($fw, $defaults)
'to'
=>
'fe80::/10'
,
'direction'
=>
'in'
),
$defaults
[
'pass'
]
);
// block all targetting port 0
foreach
(
array
(
'from_port'
,
'to_port'
)
as
$target
)
{
$fw
->
registerFilterRule
(
1
,
array
(
'ipprotocol'
=>
'inet46'
,
'protocol'
=>
'tcp/udp'
,
$target
=>
'0'
),
$defaults
[
'block'
]
);
}
// CARP defaults
$carp_disabled
=
empty
(
$config
[
'hasync'
])
&&
empty
(
$config
[
'virtualip'
][
'vip'
]);
$fw
->
registerFilterRule
(
1
,
array
(
'protocol'
=>
'carp'
,
'from'
=>
'(self)'
,
'direction'
=>
'in'
,
'disabled'
=>
$carp_disabled
),
$defaults
[
'block'
]
);
$fw
->
registerFilterRule
(
1
,
array
(
'protocol'
=>
'carp'
),
$defaults
[
'pass'
]);
}
src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php
View file @
7bc5bf4d
...
...
@@ -48,7 +48,9 @@ class FilterRule
'ipprotocol'
=>
'parsePlain'
,
'protocol'
=>
'parseReplaceSimple,tcp/udp:{tcp udp},proto '
,
'from'
=>
'parsePlain,from {,}'
,
'from_port'
=>
'parsePlain, port {,}'
,
'to'
=>
'parsePlain,to {,}'
,
'to_port'
=>
'parsePlain, port {,}'
,
'icmp6-type'
=>
'parsePlain,icmp6-type {,}'
,
'state'
=>
'parseState'
,
'label'
=>
'parsePlain,label ","'
...
...
@@ -71,7 +73,7 @@ class FilterRule
*/
private
function
parsePlain
(
$value
,
$prefix
=
""
,
$suffix
=
""
)
{
return
empty
(
$value
)
?
""
:
$prefix
.
$value
.
$suffix
.
" "
;
return
$value
==
''
?
""
:
$prefix
.
$value
.
$suffix
.
" "
;
}
/**
...
...
@@ -183,6 +185,8 @@ class FilterRule
$tmp
=
$this
->
rule
;
$tmp
[
'interface'
]
=
$interface
;
$tmp
[
'ipprotocol'
]
=
$ipproto
;
$tmp
[
'from'
]
=
empty
(
$tmp
[
'from'
])
?
"any"
:
$tmp
[
'from'
];
$tmp
[
'to'
]
=
empty
(
$tmp
[
'to'
])
?
"any"
:
$tmp
[
'to'
];
// disable rule when interface not found
if
(
!
empty
(
$interface
)
&&
empty
(
$this
->
interfaceMapping
[
$interface
][
'if'
]))
{
$tmp
[
'disabled'
]
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment