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

    Firewall rules hitcount for pfSense 2.1.5 and 2.2.4

    Scheduled Pinned Locked Moved webGUI
    50 Posts 16 Posters 17.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.
    • A Offline
      athurdent
      last edited by

      Something seems odd with pfSense handling auto-added Port Forward rules. They get a name like "USER_RULE: NAT …" and there's no tracker ID. As I use Multi-WAN and some Port Forwards were just copied from WAN1 to WAN2, pfctl -vvsr shows two rules with the same name. That breaks the new counters...
      Edit: Put in unique descriptions, still no luck.

      1 Reply Last reply Reply Quote 0
      • A Offline
        athurdent
        last edited by

        On to the next problem, Port Aliases. While pf let's us write single-line rules with something like

        port {  25  465  587 }
        

        it automatically creates a separate rule for every single port. pfctl will show three rules for the example above whilst our ruleset only has a single rule for this.

        1 Reply Last reply Reply Quote 0
        • marcellocM Offline
          marcelloc
          last edited by

          Updated the code for 2.2.4 to include kill states option for specific rule.

          rules_count_kill_states.png_thumb
          rules_count_kill_states.png

          Treinamentos de Elite: http://sys-squad.com

          Help a community developer! ;D

          1 Reply Last reply Reply Quote 0
          • marcellocM Offline
            marcelloc
            last edited by

            @athurdent:

            On to the next problem, Port Aliases. While pf let's us write single-line rules with something like

            port {  25  465  587 }
            

            it automatically creates a separate rule for every single port. pfctl will show three rules for the example above whilst our ruleset only has a single rule for this.

            I'll try to simulate it.

            Treinamentos de Elite: http://sys-squad.com

            Help a community developer! ;D

            1 Reply Last reply Reply Quote 0
            • A Offline
              athurdent
              last edited by

              @marcelloc:

              Updated the code for 2.2.4 to include kill states option for specific rule.

              Wasn't able to try it out yet. But if that means, the byte counter does not show anymore when hovering there with the mouse, that would be too bad. Maybe the Hits field could show
              Packets(Bytes)/States
              or something similar?

              1 Reply Last reply Reply Quote 0
              • marcellocM Offline
                marcelloc
                last edited by

                @athurdent:

                Wasn't able to try it out yet. But if that means, the byte counter does not show anymore when hovering there with the mouse, that would be too bad. Maybe the Hits field could show
                Packets(Bytes)/States
                or something similar?

                I'ts still working inside the td with mouse over, I've just included the option to kill when there are active states and only over the numbers.

                Treinamentos de Elite: http://sys-squad.com

                Help a community developer! ;D

                1 Reply Last reply Reply Quote 0
                • marcellocM Offline
                  marcelloc
                  last edited by

                  @athurdent:

                  Something seems odd with pfSense handling auto-added Port Forward rules. They get a name like "USER_RULE: NAT …" and there's no tracker ID.

                  Edit and save rule created by nat to force the trackerid

                  Treinamentos de Elite: http://sys-squad.com

                  Help a community developer! ;D

                  1 Reply Last reply Reply Quote 0
                  • marcellocM Offline
                    marcelloc
                    last edited by

                    @athurdent:

                    On to the next problem, Port Aliases. While pf let's us write single-line rules with something like

                    port {  25  465  587 }
                    

                    it automatically creates a separate rule for every single port. pfctl will show three rules for the example above whilst our ruleset only has a single rule for this.

                    check if new code fixes it. (v0.31)

                    @78(1439883226) pass in quick on em0 reply-to (em0 172.17.12.1) inet proto tcp from any to (self:3) port = http flags S/SA keep state label "USER_RULE: 1439883226"
                      [ Evaluations: 17        Packets: 0         Bytes: 0           States: 0     ]
                      [ Inserted: pid 23535 State Creations: 3319624344]
                    @79(1439883226) pass in quick on em0 reply-to (em0 172.17.12.1) inet proto tcp from any to (self:3) port = https flags S/SA keep state label "USER_RULE: 1439883226"
                      [ Evaluations: 17        Packets: 763       Bytes: 442121      States: 6     ]
                      [ Inserted: pid 23535 State Creations: 3319624408]
                    @80(1439883226) pass in quick on em0 reply-to (em0 172.17.12.1) inet proto tcp from any to (self:3) port = ssh flags S/SA keep state label "USER_RULE: 1439883226"
                      [ Evaluations: 1         Packets: 555       Bytes: 81812       States: 1     ]
                      [ Inserted: pid 23535 State Creations: 3321614424]
                    @81(1439883226) pass in quick on em0 reply-to (em0 172.17.12.1) inet proto tcp from any to (self:3) port = 8443 flags S/SA keep state label "USER_RULE: 1439883226"
                      [ Evaluations: 0         Packets: 0         Bytes: 0           States: 0     ]
                      [ Inserted: pid 23535 State Creations: 3321614400]
                    @82(1439883226) pass in quick on em0 reply-to (em0 172.17.12.1) inet proto tcp from any to (self:3) port = domain flags S/SA keep state label "USER_RULE: 1439883226"
                      [ Evaluations: 0         Packets: 0         Bytes: 0           States: 0     ]
                      [ Inserted: pid 23535 State Creations: 3321614376]
                    
                    

                    rules_count_kill_states_3.png_thumb
                    rules_count_kill_states_3.png

                    Treinamentos de Elite: http://sys-squad.com

                    Help a community developer! ;D

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      athurdent
                      last edited by

                      Thanks, works great.
                      But one odd thing I noticed is, that rules with multiple ports like those you fixed seem to get their counter cleared on every filter reload. At the same time, my other "normal" rules do not suffer from this.
                      Are you seeing this too, or am I doing something wrong?

                      1 Reply Last reply Reply Quote 0
                      • marcellocM Offline
                        marcelloc
                        last edited by

                        More features on version 0.4 for pfsense 2.2, now we can view hit count, list and kill States(with ajax to keep it light and fast).

                        rules_count_kill_states_3.png
                        rules_count_kill_states_3.png_thumb
                        rules_count_show_states.png
                        rules_count_show_states.png_thumb

                        Treinamentos de Elite: http://sys-squad.com

                        Help a community developer! ;D

                        1 Reply Last reply Reply Quote 0
                        • JackLJ Offline
                          JackL
                          last edited by

                          Very nice!

                          Good job as always, marcelloc!

                          []`s
                          Jack

                          Treinamentos de Elite: http://sys-squad.com
                          Soluções: https://conexti.com.br

                          1 Reply Last reply Reply Quote 0
                          • A Offline
                            athurdent
                            last edited by

                            marcelloc, the lastest update works great, thanks again.

                            Still, the new hitcount feature reveals that some rules with multiple ports like "{  25  465  587 }" or multiple protocols like "{ tcp udp }" get their packet/byte counter reset on reload. Evaluations / State Creations seem not affected. Nobody else seeing this?

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

                              Awesome feature!

                              Can't wait to see this merged upstream!  ;D

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

                                Good job.
                                Test-driving it on a 2.2.4. Works as advertised.

                                Git->Clone->Patch->Push-request this  :)

                                No "help me" PM's please. Use the forum, the community will thank you.
                                Edit : and where are the logs ??

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

                                  +1 thanks Marcello, really useful feature.
                                  Love to see that merged also  ;D

                                  4x XG-7100 (2xHA), 1x SG-4860, 1x SG-2100
                                  1x PC Engines APU2C4, 1x PC Engines APU1C4

                                  1 Reply Last reply Reply Quote 0
                                  • marcellocM Offline
                                    marcelloc
                                    last edited by

                                    Pull request sent do 2.3-DEVELOPMENT

                                    https://github.com/pfsense/pfsense/pull/1892

                                    Treinamentos de Elite: http://sys-squad.com

                                    Help a community developer! ;D

                                    1 Reply Last reply Reply Quote 0
                                    • L Offline
                                      LinuxTracker
                                      last edited by

                                      Very, very nice.

                                      (Also: One more column of info feels like a step toward widescreen display!)

                                      1 Reply Last reply Reply Quote 0
                                      • marcellocM Offline
                                        marcelloc
                                        last edited by

                                        I suggest all who cant test to do it on 2.2 and/or 2.3-devel and comment on pull request. Maybe with more people testing, it get merged faster…

                                        Treinamentos de Elite: http://sys-squad.com

                                        Help a community developer! ;D

                                        1 Reply Last reply Reply Quote 0
                                        • L Offline
                                          LinuxTracker
                                          last edited by

                                          @marcelloc:

                                          I suggest all who cant test to do it on 2.2 and/or 2.3-devel and comment on pull request. Maybe with more people testing, it get merged faster…

                                          Done.

                                          The more I play with this the more I like it.
                                          On mouseover, I get the data I was trying (unsuccessfully) to glean out of pfTop.

                                          1 Reply Last reply Reply Quote 0
                                          • marcellocM Offline
                                            marcelloc
                                            last edited by

                                            @LinuxTracker:

                                            The more I play with this the more I like it.

                                            me too.  :)

                                            @LinuxTracker:

                                            On mouseover, I get the data I was trying (unsuccessfully) to glean out of pfTop.

                                            Great!

                                            Treinamentos de Elite: http://sys-squad.com

                                            Help a community developer! ;D

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