Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login
    Introducing Netgate Nexus: Multi-Instance Management at Your Fingertips.

    Firewall Rules Processed Once Per Interface?

    Scheduled Pinned Locked Moved Firewalling
    8 Posts 4 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • calebhC Offline
      calebh
      last edited by

      I feel like this is a super simple question, but I haven't been able to confirm or deny whether it works like this…

      If a given packet comes in on the WAN and is intended for a destination on the LAN, will it get evaluated by the WAN rules and (if the WAN rules pass it) by the LAN rules? It makes sense that it would, but I wanted to double-check.

      1 Reply Last reply Reply Quote 0
      • K Offline
        kpa
        last edited by

        Yes pretty much and once per interface is also once per direction. Every packet that either enters or leaves via an interface is subject to filtering by the whole active ruleset (the ruleset you get by running pfctl -sr on the command line, forget the WebGUI representation of the rules). A packet entering from WAN and is going to the LAN network is first filtered on the WAN interface by the entire ruleset and matching rules apply, then the packet leaving via the LAN interface is again filtered using the whole ruleset and matching rules apply again.

        1 Reply Last reply Reply Quote 0
        • johnpozJ Offline
          johnpoz LAYER 8 Global Moderator
          last edited by

          No.. rules are only evaluated as they enter interface, not as they leave an interface.

          Rules are evaluated top down, first rule to trigger wins, no other rules are evaluated.

          If you need rules to be evaluated as they exit an interface, you can use the floating tab to create such rules - but these would only be required in the most complex configurations and should really never be needed.

          https://doc.pfsense.org/index.php/Firewall_Rule_Processing_Order

          An intelligent man is sometimes forced to be drunk to spend time with his fools
          If you get confused: Listen to the Music Play
          Please don't Chat/PM me for help, unless mod related
          SG-4860 25.11 | Lab VMs 2.8.1, 25.11

          1 Reply Last reply Reply Quote 0
          • chpalmerC Offline
            chpalmer
            last edited by

            @kpa:

            Yes pretty much and once per interface is also once per direction. Every packet that either enters or leaves via an interface is subject to filtering by the whole active ruleset (the ruleset you get by running pfctl -sr on the command line, forget the WebGUI representation of the rules). A packet entering from WAN and is going to the LAN network is first filtered on the WAN interface by the entire ruleset and matching rules apply, then the packet leaving via the LAN interface is again filtered using the whole ruleset and matching rules apply again.

            If that were true then pfSense would not be usable in its default form.  Think of the fact that the WAN interface comes without rules but will still pass traffic initiated by the LAN interface.  :)

            Triggering snowflakes one by one..
            Intel(R) Core(TM) i5-4590T CPU @ 2.00GHz on an M400 WG box.

            1 Reply Last reply Reply Quote 0
            • johnpozJ Offline
              johnpoz LAYER 8 Global Moderator
              last edited by

              So no basic understanding of states then I take it ;)

              Your answer from what the lan requested is allowed back in because the outbound connection allowed by the lan rule creates a state, the server you talked to on the internet is allowed back in because of the state.

              An intelligent man is sometimes forced to be drunk to spend time with his fools
              If you get confused: Listen to the Music Play
              Please don't Chat/PM me for help, unless mod related
              SG-4860 25.11 | Lab VMs 2.8.1, 25.11

              1 Reply Last reply Reply Quote 0
              • K Offline
                kpa
                last edited by

                @chpalmer:

                @kpa:

                Yes pretty much and once per interface is also once per direction. Every packet that either enters or leaves via an interface is subject to filtering by the whole active ruleset (the ruleset you get by running pfctl -sr on the command line, forget the WebGUI representation of the rules). A packet entering from WAN and is going to the LAN network is first filtered on the WAN interface by the entire ruleset and matching rules apply, then the packet leaving via the LAN interface is again filtered using the whole ruleset and matching rules apply again.

                If that were true then pfSense would not be usable in its default form.  Think of the fact that the WAN interface comes without rules but will still pass traffic initiated by the LAN interface.  :)

                Well I left out the state mechanism on purpose because it's a minor complication that just adds "dynamic rules" that are just rules like all the others for filtering purposes.

                1 Reply Last reply Reply Quote 0
                • johnpozJ Offline
                  johnpoz LAYER 8 Global Moderator
                  last edited by

                  Minor complication?

                  How can you leave out states when talking about a stateful firewall?  Which is what pfsense is.. There has not be nonstateful firewall YEARS!  Even the your cheap 20$ soho router is stateful..

                  If you were non stateful the only way you could work would be if your wan was really Any Any.. And how exactly would you be doing the napt without states?

                  An intelligent man is sometimes forced to be drunk to spend time with his fools
                  If you get confused: Listen to the Music Play
                  Please don't Chat/PM me for help, unless mod related
                  SG-4860 25.11 | Lab VMs 2.8.1, 25.11

                  1 Reply Last reply Reply Quote 0
                  • K Offline
                    kpa
                    last edited by

                    That's not what I mean. If you look at what PF does at the bottom level the state comparison and filter rules aren't that different, packets are compared against rules or states and the comparisons are based on the exact same information. The only clever part is the state creation in case a filter rule is marked as a state creating one.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Copyright 2026 Rubicon Communications LLC (Netgate). All rights reserved.