OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • How the firewall rule work?
« previous next »
  • Print
Pages: [1]

Author Topic: How the firewall rule work?  (Read 1611 times)

doremo

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
How the firewall rule work?
« on: September 24, 2023, 05:17:58 am »
I am having difficulty understanding the logic of OPNSense firewall rules. Based on my experience with FortiGate, I configured the following rules in OPNSense, but they are not working as expected in OPNSense. I need help from an expert to troubleshoot the issue.

My requirements are:
1.Allow a specific IP address range to access the internet
2.Block a specific IP address from accessing the specific network devices

My OPNSense firewall rule configuration:

**Rule 1**
Interface: LAN
Direction: In
Source: Private IP scope alias
Destination: WAN
Source to destination port: Any
Action: Allow

**Rule 2**
Interface: LAN
Direction: In
Source: Host IP address
Destination: Network Devices IP address Alias
Source to destination port: Any
Action: Block
« Last Edit: September 24, 2023, 05:19:31 am by doremo »
Logged

Monviech (Cedrik)

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1659
  • Karma: 178
    • View Profile
Re: How the firewall rule work?
« Reply #1 on: September 24, 2023, 10:05:47 am »
Firewall rules are first match wins. If you create an allow rule and it matched before a block rule, then the allow rule wins.

Your basic structure could be:
- The most specific rules should come first (e.g. one source host to one destination host)
- The most permissive rules should be last (e.g. any source to any destination)
-Block rules should be at the right spot, most of the time between the most specific and the most permissive rules, so that they can match and block before its allowed by the most permissive allow rules.
- Creating an Alias with the RFC1918 networks and using that alias as inverted destination in the internet allow rule (opposed to "wan" or "any" as destination) makes many block rules obsolete.
Logged
Hardware:
DEC740

Bob.Dig

  • Sr. Member
  • ****
  • Posts: 259
  • Karma: 13
    • View Profile
Re: How the firewall rule work?
« Reply #2 on: September 24, 2023, 10:28:00 am »
There is no destination "WAN". And everything with WAN only means the WAN-address and that network, which is never the whole internet. Internet is always "any".
Logged

CJ

  • Hero Member
  • *****
  • Posts: 832
  • Karma: 30
    • View Profile
    • Have Answer, Will Blog
Re: How the firewall rule work?
« Reply #3 on: September 24, 2023, 02:49:00 pm »
Quote from: Monviech on September 24, 2023, 10:05:47 am
Firewall rules are first match wins. If you create an allow rule and it matched before a block rule, then the allow rule wins.

That's usually the case unless you've unchecked Quick when creating a rule.
Logged
Have Answer, Will Blog

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • How the firewall rule work?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2