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

    pfsense-rule-order: script to keep firewall rules in the right order automatically

    Scheduled Pinned Locked Moved Firewalling
    19 Posts 4 Posters 391 Views 4 Watching
    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.
    • tinfoilmattT Offline
      tinfoilmatt LAYER 8 @ngf
      last edited by

      There are package settings which address auto-added rule ordering. Do those not cover your situation?

      ngfN 1 Reply Last reply Reply Quote 0
      • ngfN Offline
        ngf @tinfoilmatt
        last edited by

        @tinfoilmatt said in pfsense-rule-order: script to keep firewall rules in the right order automatically:

        There are package settings which address auto-added rule ordering. Do those not cover your situation?

        I looked at the pfBlockerNG rule order settings but they control where pfBlockerNG places its own auto rules relative to manual ones, not the order of manual rules themselves.
        my issue was specifically manual rules getting reordered relative to each other, so those settings didn't help in my case.

        tinfoilmattT 1 Reply Last reply Reply Quote 0
        • tinfoilmattT Offline
          tinfoilmatt LAYER 8 @ngf
          last edited by tinfoilmatt

          my issue was specifically manual rules getting reordered relative to each other

          This wouldn't be caused by pfBlockerNG's cron job. The order of non-pfBlockerNG auto-added rules (i.e., 'manual rules') could only be changed manually.

          What do you have for that package setting—"Firewall > pfBlockerNG > IP > IP Interface/Rules Configuration > Firewall 'Auto' Rule Order"?

          ngfN 1 Reply Last reply Reply Quote 0
          • ngfN Offline
            ngf @tinfoilmatt
            last edited by

            @tinfoilmatt said in pfsense-rule-order: script to keep firewall rules in the right order automatically:

            Firewall 'Auto' Rule Order

            aa4b408f-ea7b-4cc8-a7c8-c0cffee10854-image.png

            tinfoilmattT 1 Reply Last reply Reply Quote 0
            • tinfoilmattT Offline
              tinfoilmatt LAYER 8 @ngf
              last edited by

              Interesting. So those last two settings in the drop-down can and do affect 'manual rule' ordering.

              So then why not use the default setting which leaves "All other rules" unaffected by pfBlockerNG?

              ngfN 1 Reply Last reply Reply Quote 0
              • ngfN Offline
                ngf @tinfoilmatt
                last edited by

                @tinfoilmatt I was not aware that this setting also affects manual rule ordering.
                i will change back to the default and disable the script temporarily to see if that alone solves the problem.
                thank you very much.

                tinfoilmattT 1 Reply Last reply Reply Quote 0
                • tinfoilmattT Offline
                  tinfoilmatt LAYER 8 @ngf
                  last edited by tinfoilmatt

                  Additionally (and with the default setting there)—if for whatever reason you need a pass rule above pfBlockerNG's auto-added block rules, then the way to do that would be by way of the "Permit" feed group action options (i.e., actions "Permit Inbound" for WAN interface/s, "Permit Outbound" for LAN interface/s, or "Permit Both"). This would be the cleanest and most automated way to "whitelist" any pfBlockerNG false positives.

                  ngfN 1 Reply Last reply Reply Quote 0
                  • ngfN Offline
                    ngf @tinfoilmatt
                    last edited by

                    @tinfoilmatt said in pfsense-rule-order: script to keep firewall rules in the right order automatically:

                    Additionally (and with the default setting there)—if for whatever reason you need a pass rule above pfBlockerNG's auto-added block rules, then the way to do that would be by way of the "Permit" feed group action options (i.e., actions "Permit Inbound" for WAN interface/s, "Permit Outbound" for LAN interface/s, or "Permit Both"). This would be the cleanest and most automated way to "whitelist" any pfBlockerNG false positives.

                    Thanks, I'll check with the default setting.
                    If that solves the reordering problem, the script is still useful as a general safety net for rule ordering, but the main reason here was clearly misconfiguration on my part.

                    tinfoilmattT 1 Reply Last reply Reply Quote 0
                    • tinfoilmattT Offline
                      tinfoilmatt LAYER 8 @ngf
                      last edited by

                      At one point, I would've spent a lot of time parsing that blue infoblock in my own mind. I'm certain there are good use cases for the non-default options. But it either never occured to me, or I had forgotten that those last two do affect non-pfBlockerNG rule ordering. Thanks for the refresher.

                      By the way, I like what you're doing with your blocklist-manager tool.

                      ngfN 1 Reply Last reply Reply Quote 0
                      • ngfN Offline
                        ngf @tinfoilmatt
                        last edited by

                        @tinfoilmatt same here, i had no idea that setting affected manual rules until now, good to know.

                        🙏 thanks for the kind words on blocklist-manager, glad it's useful!

                        GertjanG 1 Reply Last reply Reply Quote 0
                        • GertjanG Offline
                          Gertjan @ngf
                          last edited by

                          @ngf

                          A newer pfSense will also give you access to the latest version pfBlockerng.
                          Your issue might auto solve itself.

                          No "help me" PM's please. Use the forum, the community will thank you.

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