Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Strange error: There were error(s) loading the rules: pfctl: pfctl_rules

    General pfSense Questions
    13
    102
    15.8k
    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.
    • stephenw10S
      stephenw10 Netgate Administrator
      last edited by

      You can make it more verbose with extra v flags. But I expect it to at least return something:

      [22.05-RELEASE][admin@4100-2.stevew.lan]/root: pfctl -vvf /tmp/rules.bad
      Loaded 762 passive OS fingerprints
      

      Returning only an error like that can be a kernel/world mismatch. Has it just been updated?

      Steve

      F 1 Reply Last reply Reply Quote 0
      • F
        Flole @stephenw10
        last edited by

        @stephenw10 I've ruled out a mismatch (and it worked after the update, so this is most likely not related to the update). The system was rebooted and then this apparently appeared.

        The extra -v flags do cause that os fingerprint message to appear, but then only the pfctl_rules thing again with an exit code of 1.

        1 Reply Last reply Reply Quote 0
        • stephenw10S
          stephenw10 Netgate Administrator
          last edited by

          Can you run any pfctl command? Like: pfctl -sr

          F 1 Reply Last reply Reply Quote 0
          • F
            Flole @stephenw10
            last edited by

            @stephenw10 -sr is quiet but exit code is 0. When I do -sa I even get my configured aliases as a table, so apparently it all worked for a short time after rebooting so the rules and aliases were loaded properly.

            1 Reply Last reply Reply Quote 0
            • stephenw10S
              stephenw10 Netgate Administrator
              last edited by

              This is in 2.6 on custom hardware?

              F 1 Reply Last reply Reply Quote 0
              • F
                Flole @stephenw10
                last edited by

                @stephenw10 No, it's on 22.05. I'm sure a downgrade would fix it and I have the recovery image here already, but it would probably be better to do further debugging to see what causes pfctl to get in a state where it not longer wants to accept rules.

                1 Reply Last reply Reply Quote 0
                • stephenw10S
                  stephenw10 Netgate Administrator
                  last edited by

                  The only time I've been able to explain that is when there was a kernell mismatch causing pfctl not to function as expected with pf in the kernel.

                  Try:

                  [22.05-RELEASE][admin@4100-2.stevew.lan]/root: sha256 /sbin/pfctl
                  SHA256 (/sbin/pfctl) = 4f9310145dfe739126392d77e7cb37d8cf845317f10624fb8b2fd1e408323761
                  [22.05-RELEASE][admin@4100-2.stevew.lan]/root: uname -a
                  FreeBSD 4100-2.stevew.lan 12.3-STABLE FreeBSD 12.3-STABLE plus-RELENG_22_05-n202700-3ddaea61055 pfSense  amd64
                  [22.05-RELEASE][admin@4100-2.stevew.lan]/root: freebsd-version -kur
                  12.3-STABLE
                  12.3-STABLE
                  12.3-STABLE
                  
                  F 1 Reply Last reply Reply Quote 0
                  • F
                    Flole @stephenw10
                    last edited by

                    That matches:

                    [22.05-RELEASE][root@XXXXXXX]/root: sha256 /sbin/pfctl
                    SHA256 (/sbin/pfctl) = 4f9310145dfe739126392d77e7cb37d8cf845317f10624fb8b2fd1e408323761
                    [22.05-RELEASE][root@XXXXXXX]/root: uname -a
                    FreeBSD XXXXXXXXXXXX 12.3-STABLE FreeBSD 12.3-STABLE plus-RELENG_22_05-n202700-3ddaea61055 pfSense  amd64
                    [22.05-RELEASE][root@XXXXXXX]/root: freebsd-version -kur
                    12.3-STABLE
                    12.3-STABLE
                    12.3-STABLE
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • stephenw10S
                      stephenw10 Netgate Administrator
                      last edited by

                      Hmm, that's on custom hardware? Updated from CE to Plus?

                      F 1 Reply Last reply Reply Quote 0
                      • F
                        Flole @stephenw10
                        last edited by Flole

                        It was on Plus 22.01, then it got upgraded to 22.05 and it worked perfectly fine. Then there was a power outage so the firewall got shutdown (graceful shutdown when the UPS ran out of battery) and after it booted again this issue started to appear. As there are multiple users affected by this apparently and rebooting sometimes seems to solve it (at least for others, for me it doesn't for some reason) there is probably some nasty bug somewhere. Shouldn't pfctl normally return an error message if something is not right?

                        1 Reply Last reply Reply Quote 0
                        • stephenw10S
                          stephenw10 Netgate Administrator
                          last edited by

                          It does if there's an error in the ruleset, yes. It doesn't if the rules file is empty though:

                          [22.05-RELEASE][admin@4100-2.stevew.lan]/root: pfctl -vvvf /tmp/rules.bad
                          Loaded 762 passive OS fingerprints
                          [22.05-RELEASE][admin@4100-2.stevew.lan]/root: echo $?
                          0
                          

                          We have seen devices load a kernel from another storage device but I've never been able to replicate that here. Obviously that only applies if you have more than one drive in the system.
                          And it doesn't appear to have happened here since the ported kernel is correct.

                          However the other symptoms point to that.

                          Are there any errors in the boot log?

                          F 1 Reply Last reply Reply Quote 0
                          • F
                            Flole @stephenw10
                            last edited by

                            @stephenw10 said in Strange error: There were error(s) loading the rules: pfctl: pfctl_rules:

                            It does if there's an error in the ruleset, yes. It doesn't if the rules file is empty though:

                            You are getting exit code 0 there though, I am getting exit code 1 there.

                            @stephenw10 said in Strange error: There were error(s) loading the rules: pfctl: pfctl_rules:

                            We have seen devices load a kernel from another storage device but I've never been able to replicate that here. Obviously that only applies if you have more than one drive in the system.

                            It's a single drive only. I always wanted to migrate to ZFS though and use mirroring on this system, so maybe it's a good time now to backup the config and reinstall using ZFS on 2 drives.

                            I just saw in the system log this message from snort being logged:

                            s2c_pf_block() => ioctl() DIOCRADDADDRS: No such process
                            

                            So maybe this gives more information on what's going on? I assume the same ioctl call is being made by pfctl aswell and most likely the same error is returned there? Just that pfctl isn't displaying that error.

                            In the boot log I am only seeing this error, but it seems unrelated:

                            dummynet: bad switch 21!
                            
                            1 Reply Last reply Reply Quote 0
                            • stephenw10S
                              stephenw10 Netgate Administrator
                              last edited by

                              Yeah those errors all point to a mismatch in something but I'm unsure what if the kernel and pfctl are correct.

                              The quickest way back up is going to be a re-install though.

                              Steve

                              F 1 Reply Last reply Reply Quote 0
                              • F
                                Flole @stephenw10
                                last edited by

                                Maybe it's the library thats not matching? Snort doesn't call pfctl I think, if it uses the library which pfctl also uses and that one is corrupted/wrong that could explain it.

                                sha256sum ./usr/lib/libpfctl*
                                bd164a6f18720e395fae0b30ae552afb04b5a86919e9ab8e0ba433678ef5b75b  ./usr/lib/libpfctl.a
                                aa7aa511a5d26c453dbbae04568ae5cecd39407d2b53be1fc66d51669af796c4  ./usr/lib/libpfctl.so
                                aa7aa511a5d26c453dbbae04568ae5cecd39407d2b53be1fc66d51669af796c4  ./usr/lib/libpfctl.so.5
                                
                                bmeeksB stephenw10S 2 Replies Last reply Reply Quote 0
                                • bmeeksB
                                  bmeeks @Flole
                                  last edited by

                                  @flole said in Strange error: There were error(s) loading the rules: pfctl: pfctl_rules:

                                  Maybe it's the library thats not matching? Snort doesn't call pfctl I think, if it uses the library which pfctl also uses and that one is corrupted/wrong that could explain it.

                                  sha256sum ./usr/lib/libpfctl*
                                  bd164a6f18720e395fae0b30ae552afb04b5a86919e9ab8e0ba433678ef5b75b  ./usr/lib/libpfctl.a
                                  aa7aa511a5d26c453dbbae04568ae5cecd39407d2b53be1fc66d51669af796c4  ./usr/lib/libpfctl.so
                                  aa7aa511a5d26c453dbbae04568ae5cecd39407d2b53be1fc66d51669af796c4  ./usr/lib/libpfctl.so.5
                                  

                                  As the author of the custom Snort plugin I can tell you how it works. It is making direct ioctl() system calls for all of its operations with the packet filter firewall. Those system calls will wind up using the library. You have a corrupted installation with mismatching versions of core system libraries.

                                  F 1 Reply Last reply Reply Quote 1
                                  • stephenw10S
                                    stephenw10 Netgate Administrator @Flole
                                    last edited by

                                    Looks like the expected values:

                                    [22.05-RELEASE][admin@4100-2.stevew.lan]/root: sha256 /usr/lib/libpfctl*
                                    SHA256 (/usr/lib/libpfctl.a) = bd164a6f18720e395fae0b30ae552afb04b5a86919e9ab8e0ba433678ef5b75b
                                    SHA256 (/usr/lib/libpfctl.so) = aa7aa511a5d26c453dbbae04568ae5cecd39407d2b53be1fc66d51669af796c4
                                    SHA256 (/usr/lib/libpfctl.so.5) = aa7aa511a5d26c453dbbae04568ae5cecd39407d2b53be1fc66d51669af796c4
                                    
                                    1 Reply Last reply Reply Quote 0
                                    • bmeeksB
                                      bmeeks
                                      last edited by

                                      Did you by chance, at any point in the recent past, install some third-party package or otherwise switch the pkg repo pointer? The symptoms sound like some libraries on the system do not now match up with others.

                                      F 1 Reply Last reply Reply Quote 0
                                      • F
                                        Flole @bmeeks
                                        last edited by

                                        @bmeeks said in Strange error: There were error(s) loading the rules: pfctl: pfctl_rules:

                                        You have a corrupted installation with mismatching versions of core system libraries.

                                        Not entirely sure how that could happen by simply rebooting and why the initial loading of the rules when booting works (aswell as querying the rules/tables and so on) though. To me that sounds like something after the initial loading is causing those errors, otherwise no rules would be loaded?

                                        Others solved the same behaviour by rebooting, that obviously doesn't fix a mismatched version.

                                        bmeeksB 1 Reply Last reply Reply Quote 0
                                        • stephenw10S
                                          stephenw10 Netgate Administrator
                                          last edited by

                                          I suspect in the cases that fixed this by simply rebooting it had somehow loaded an old kernel from a different device.

                                          I assume you are running Snort?

                                          F 1 Reply Last reply Reply Quote 0
                                          • F
                                            Flole @bmeeks
                                            last edited by

                                            @bmeeks said in Strange error: There were error(s) loading the rules: pfctl: pfctl_rules:

                                            Did you by chance, at any point in the recent past, install some third-party package or otherwise switch the pkg repo pointer? The symptoms sound like some libraries on the system do not now match up with others.

                                            No I didn't, I did a normal reboot and since then things started acting in this weird way. I don't think I updated any packages since I upgraded to 2.6.0 (and that was already a few weeks ago). A messed up library would be used immediately without rebooting though.

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