OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • [SOLVED] Rule order
« previous next »
  • Print
Pages: [1]

Author Topic: [SOLVED] Rule order  (Read 6645 times)

flushell

  • Newbie
  • *
  • Posts: 43
  • Karma: 3
    • View Profile
[SOLVED] Rule order
« on: January 21, 2019, 09:22:08 am »
I understand that rules are executed from top to bottom.
That is why "block" rules come after "allow" rules.

One thing is hard to grasp for me and I can't find the answer on internet or this forum (or maybe the answer is there, but I don't see it):

When I add a rule to the firewall for something to pass, let's say this simple rule:
- LAN segment pass all DNS (53).
And AFTER that:
- Specific host (but IN the LAN segment above) block DNS (53)

Will the second rule be effective? In my tests it is effective, so there's my answer. But shouldn't the rule execution STOP after the first rule (because it matched)... Am I missing something?

edit: typo
« Last Edit: January 21, 2019, 09:01:16 pm by franco »
Logged

chemlud

  • Hero Member
  • *****
  • Posts: 2488
  • Karma: 112
    • View Profile
Re: Rule order
« Reply #1 on: January 21, 2019, 10:56:41 am »
...screenshot of rule set...
... how did you check which rule worked?
Logged
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

felix eichhorns premium katzenfutter mit der extraportion energie

A router is not a switch - A router is not a switch - A router is not a switch - A rou....

flushell

  • Newbie
  • *
  • Posts: 43
  • Karma: 3
    • View Profile
Re: Rule order
« Reply #2 on: January 21, 2019, 07:49:47 pm »
Quote from: chemlud on January 21, 2019, 10:56:41 am
...screenshot of rule set...
... how did you check which rule worked?


Oke. Yesterday I thought I had tested this thoroughly.
Did it again, to make screenshots.
Turns out I was wrong. The rule execution stops after the first 'hit'.
I don't know what happened yesterday...

Also found this which explains it very well and applies to this.


Quote
Longer Version

More accurately, the following order (still simplified) is found in the ruleset (Check /tmp/rules.debug):


    Outbound NAT rules
    Inbound NAT rules such as Port Forwards (including rdr pass and UPnP)
    NAT rules for the Load Balancing daemon (relayd)
    Rules dynamically received from RADIUS for IPsec and OpenVPN clients
    Internal automatic rules (pass and block for various items like lockout, snort, DHCP, etc.)
    User-defined rules:
        Rules defined on the floating tab
        Rules defined on interface group tabs (Including IPsec and OpenVPN)
        Rules defined on interface tabs (WAN, LAN, OPTx, etc)
    Automatic VPN rules

My confusion was from the fact that a NAT rule is processed before a User Defined Rule.
Makes sense now.

Thanks for replying.
This can be closed.

« Last Edit: January 21, 2019, 08:00:14 pm by flushell »
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17706
  • Karma: 1618
    • View Profile
Re: [SOLVED] Rule order
« Reply #3 on: January 21, 2019, 09:01:31 pm »
Marked as solved, thanks for the feedback. :)
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • [SOLVED] Rule order
 

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