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

    PF States limit reached.

    Scheduled Pinned Locked Moved Firewalling
    18 Posts 6 Posters 3.9k Views 8 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.
    • B Offline
      beatvjiking
      last edited by

      I've seen state tables that size only in instances when malware is in play, or in one case, when an intern for a well-known antimalware company wrote a naive script querying their entire list of malicious domains with no limits on queries per second.

      You may also want to try setting firewall optimization to "aggressive" but the preferable option is to limit max src states.

      X 1 Reply Last reply Reply Quote 0
      • X Offline
        xciter327 @beatvjiking
        last edited by xciter327

        @beatvjiking said in PF States limit reached.:

        I've seen state tables that size only in instances when malware is in play, or in one case, when an intern for a well-known antimalware company wrote a naive script querying their entire list of malicious domains with no limits on queries per second.

        You may also want to try setting firewall optimization to "aggressive" but the preferable option is to limit max src states.

        My thinking exactly. This is a student network, so god knows what are they trying to do.

        Interestingly enough some time ago I was doing tests with hping and packet generator(pktgen I think) and I have managed to fully load up the device (full CPU, full state table etc, interfaces at capacity), however normally after I stop the test the device always recovered. It crashed only once, from many test, but I could not reproduce it. This full lockup I've never managed to reproduce.

        This is exactly why the states numbers have been raised. I've tested it up to 5M states with no issues.

        1 Reply Last reply Reply Quote 0
        • ? Offline
          A Former User
          last edited by

          I read the doco the same way, why doesn't the firewall start just nuking sessions straight away? It shouldn't be possible to hit 5M with your config.

          I agree that's not the right solution for your problem, but regardless, shouldn't this be working for you?

          1 Reply Last reply Reply Quote 0
          • X Offline
            xciter327
            last edited by

            That was my thinking exactly. I've just added the "max src states" to all the firewall rules(which are pass).

            1 Reply Last reply Reply Quote 0
            • X Offline
              xciter327
              last edited by xciter327

              Also the firewall had a kernel panic on reboot.(decide to reboot it because the graphs were not working).

              0_1537343874714_df984a18-4f5d-424f-a287-2d0fdd66e793-image.png

              I checked in /var/crashes and there was no dump.

              1 Reply Last reply Reply Quote 0
              • H Offline
                heper
                last edited by

                So this problem happens every 200 days or so? Uptime in screenshot.....

                1 Reply Last reply Reply Quote 0
                • X Offline
                  xciter327
                  last edited by

                  No it happens once a day for the last 3 days. I don't reboot the firewall, I just flush the states. "pfctl -F states all"

                  1 Reply Last reply Reply Quote 0
                  • X Offline
                    xciter327
                    last edited by

                    Just wanted to report it has not happened since I put the limits on.

                    1 Reply Last reply Reply Quote 1
                    • B Offline
                      beatvjiking
                      last edited by

                      You can probably find in your logs what device(s) are attempting to open so many sessions and address whatever is happening - i.e. malware or what have you.

                      1 Reply Last reply Reply Quote 0
                      • X Offline
                        xciter327
                        last edited by

                        Just to report it happened again. In my eyes, there are two options: Option 1 is adaptive timeouts are not working. Option 2 is the device somehow running out of memory. I can see in the monitoring graph that when the states reach roughly 900k the device becomes un-resposive. I've set much lower adaptive timeouts now and put the max states to 5mil(8G RAM). max src states is at 8096 on each firewall rule.

                        If anybody has a suggestion on how to simulate a lot of connection states from multiple IP, I would love to hear it.

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          SteveITS Rebel Alliance
                          last edited by

                          You're not alone: https://www.google.com/search?client=firefox-b-1-d&channel=cus&q=pfsense+pf+states+limit+reached

                          this one mentions a Spiceworks scan of a large subnet:
                          https://forum.netgate.com/topic/81059/zone-pf-states-pf-states-limit-reached-how-to-find-the-offender/10
                          Given that post (simultaneous scan), how often are the adaptive timeouts processed/changed/updated by pfSense? (instantly, every 5 minutes, etc.)

                          Only install packages for your version, or risk breaking it. Select your branch in System/Update/Update Settings.
                          When upgrading, allow 10-15 minutes to reboot, or more depending on packages, and device or disk speed.
                          Upvote 👍 helpful posts!

                          1 Reply Last reply Reply Quote 0
                          • B Offline
                            beatvjiking
                            last edited by

                            When I recommended 8k states, that was a very high ceiling. It works well in my environment but in most environments that can be far far lower with no negative impacts on user experience. 512 is a reasonable limit to impose on your allow rules. You may want to try that as an alternative to more RAM :)

                            1 Reply Last reply Reply Quote 0
                            • DerelictD Offline
                              Derelict LAYER 8 Netgate
                              last edited by

                              Is this running on Hyper-V?

                              Chattanooga, Tennessee, USA
                              A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                              DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                              Do Not Chat For Help! NO_WAN_EGRESS(TM)

                              X 1 Reply Last reply Reply Quote 0
                              • X Offline
                                xciter327 @Derelict
                                last edited by

                                @Derelict said in PF States limit reached.:

                                Is this running on Hyper-V?

                                Appreciate your reply. It is on a physical box. Supemicro Atom C2750.

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