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

    How to reset state table with cron.

    Scheduled Pinned Locked Moved General pfSense Questions
    15 Posts 5 Posters 2.5k Views 5 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.
    • D Offline
      D3messiah @kiokoman
      last edited by D3messiah

      @kiokoman Thanks. I made a script to check state and reset it when reaches to 20k. do cron job check every 10 min :
      Have to do this as my modem became so slow if state gets too high.
      #!/bin/sh
      stat=$(pfctl -s info | grep current | awk -F " " '{print $3}')
      if [ $stat -gt 20000 ]
      then
      # reset state
      pfctl -F state
      fi

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

        Makes no sense at all.. "Modems" don't have an idea on "how" many states you might have open or or sitting in a idle state, or waiting to close, etc...

        20k states is not very many to be honest.. How many users? 20k would be a lot for 1 or 2 users.. Just killing states out of the blue not really a good idea, since it would kill all active connections and things would have to reconnect. Are you running p2p or something that could generate a high number of states?

        Prob be better to look into removing stale states faster.. You might want to set aggressive as you firewall optimization setting under system / advanced / firewall & nat.

        Or if need be you can adjust specific state timeouts..

        What are you running pfsense on? Again a "modem" has no idea how many states your firewall would have open.. A modem is not a stateful anything.. Firewalls are stateful..

        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.07.1 | Lab VMs 2.8.1, 25.07.1

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

          @johnpoz said in How to reset state table with cron.:

          A modem is not a stateful anything.. Firewalls are stateful..

          Probably not a "modem" but an ISP router that has a built-in modem and a firewall of its own.

          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)

          noplanN 1 Reply Last reply Reply Quote 0
          • noplanN Offline
            noplan @Derelict
            last edited by

            Just out of the blue

            Why should u use the script to kill
            The states via cron...

            Is there a use case that someone can explain ;)

            To be honest I never thought of this, the one time was when optimize fail over n switch back of multi Wan

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

              @Derelict said in How to reset state table with cron.:

              Probably not a "modem" but an ISP router that has a built-in modem and a firewall of its own.

              Concur - but killing states on downstream router (pfsense), not going to clear those.. If anything it would leave them hanging..

              If I had to guess, is he prob had something using up his bandwdith.. And killing that via killing states freed that up..

              Killing all states on pfsense is not the solution here, can tell you that much.

              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.07.1 | Lab VMs 2.8.1, 25.07.1

              noplanN 1 Reply Last reply Reply Quote 0
              • noplanN Offline
                noplan @johnpoz
                last edited by

                @johnpoz

                got this one
                Thx

                1 Reply Last reply Reply Quote 0
                • D Offline
                  D3messiah @johnpoz
                  last edited by D3messiah

                  @johnpoz 20k states does not mean you have 20k users. 1 user could make 10k active connections like downloading lot of torrents.Yes it is a roiuter sorry not modem. PLDT and Converge routers has these problem with their routers . I use VPN to reduce these problem so that only the VPN pipe the modem can see. However I dont tunnel all connections, real time traffic will be lag if I pass it on vpn.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    D3messiah @noplan
                    last edited by D3messiah

                    @noplan YEs PLDT Home fiber has these problem, I use to pass some traffic to vpn to reduce the problem. Whenever active states reaches 20k sometimes my internet disconnected or it gets laggy. when I flush the states it gets back to normal.

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

                      Yeah you have fun with that...

                      20k states does not mean you have 20k users.

                      Just at a loss for words, really..

                      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.07.1 | Lab VMs 2.8.1, 25.07.1

                      D 1 Reply Last reply Reply Quote 0
                      • D Offline
                        D3messiah @johnpoz
                        last edited by D3messiah

                        @johnpoz I have lot of wifi vending machine connected to my internet.
                        1601119104308.jpg

                        1 Reply Last reply Reply Quote 0
                        • noplanN Offline
                          noplan
                          last edited by

                          Wifi vending machine...
                          So cool!

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

                            You should get internet service that doesn't suck.

                            Or put whatever device is in front of pfSense in bridge mode, etc.

                            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)

                            noplanN 1 Reply Last reply Reply Quote 0
                            • noplanN Offline
                              noplan @Derelict
                              last edited by

                              @Derelict

                              Exactly what the ISP service line did saturday
                              with one of our Wan connections here
                              Settin this box in bridge mode or as they call it dummy mode

                              After they did it
                              A) connection improved
                              B) speed improved
                              C) more noise (cuz lack of providers global block list)

                              Feels goood

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