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

Advanced Options - Multiple State / Connection Controls Not Working

Scheduled Pinned Locked Moved 2.1 Snapshot Feedback and Problems - RETIRED
31 Posts 4 Posters 10.6k 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.
  • K
    ky41083 Banned
    last edited by Jul 20, 2013, 4:19 AM

    Also, while I'm on that train of thought, I have also tried every other state limiting option and the established connections limiting option under "Advanced Options" and either all of them seem to have an effect (with the older snapshots) or none of them seem to have an effect (with the latest snapshots, at least a months worth or so).

    1 Reply Last reply Reply Quote 0
    • K
      kejianshi
      last edited by Jul 20, 2013, 4:24 AM

      The newer ones have an effect for me.  They break my connections rather than limiting them.

      1 Reply Last reply Reply Quote 0
      • K
        ky41083 Banned
        last edited by Jul 20, 2013, 4:38 AM

        The absolute only thing I have had consistent success with, if you can call it that, is globally limiting the number of sessions. But as I said in my first post, this disrupts LAN services, especially internal DNS.

        1 Reply Last reply Reply Quote 0
        • K
          ky41083 Banned
          last edited by Jul 20, 2013, 4:57 AM Jul 20, 2013, 4:42 AM

          Here is a copy of my /tmp/rules.debug, IP's masked, quickly proofed, IP masks should be consistent.

          It does indeed appear that those limits are not being applied to any rules.

          Edit: With those values in all 4 fields (Maximum state entries this rule can create, Maximum number of unique source hosts, Maximum number of established connections per host, Maximum state entries per host) this is the result from /tmp/rules.debug:

          pass  in  quick  on $LAN inet from 192.168.1.0/24 to ! $PrivateIPv4  label "USER_RULE: Session Limit Internet Traffic"

          Same is true with the rule on the WAN interface, no additional parameters appear.

          rules.debug.txt

          1 Reply Last reply Reply Quote 0
          • K
            kejianshi
            last edited by Jul 20, 2013, 5:03 AM Jul 20, 2013, 4:59 AM

            Its strange that it applies to nothing. 
            Whenever I've attempted to apply a limit to the port associated to the port that forwards to my mjpeg tilt/pan cameras, it has effectively killed the port.  I've applied connection/second and max states and both have had an effect that feels like a DOS attack. The ports just seem to work rarely when I apply limits.  It must be affecting some parameter somewhere.

            1 Reply Last reply Reply Quote 0
            • K
              kejianshi
              last edited by Jul 20, 2013, 5:24 AM

              I've actually checked this.  I have access to computers all over the globe (I do some admin here and there) and I have checked the effects of those settings outside my networks.  It makes a difference.  Not a good difference or expected difference, but a difference never the less.

              1 Reply Last reply Reply Quote 0
              • K
                kejianshi
                last edited by Jul 20, 2013, 5:34 AM

                Don't get discouraged.  Explain your findings.  I'd love to know why this isn't working as expected.

                1 Reply Last reply Reply Quote 0
                • K
                  ky41083 Banned
                  last edited by Jul 20, 2013, 6:01 AM

                  Not discouraged, just waiting to see if a dev will notice and chime in. Will most likely create a bug report on the issue tracker if nothing that makes solid repeatable sense comes up first.

                  Clearly none of the values are being applied at all, not even in the wrong location, according to the /tmp/rules.debug log.

                  1 Reply Last reply Reply Quote 0
                  • K
                    kejianshi
                    last edited by Jul 20, 2013, 6:05 AM

                    I also had same feeling as you, but I've been too busy to dig into the "why" of it the way you have.
                    I think that you are correct that its not working as advertised.
                    Do you have a proposed fix?  Can you see where the failure is?

                    1 Reply Last reply Reply Quote 0
                    • K
                      kejianshi
                      last edited by Jul 20, 2013, 6:27 AM

                      Have you done a pfctl -sa dump into a file then apply a rule and pfctl -sa into a seperate file and compare the files?
                      See if there are differences?

                      1 Reply Last reply Reply Quote 0
                      • K
                        ky41083 Banned
                        last edited by Jul 20, 2013, 6:34 AM

                        The failure is the script that reads / parses the saved options and turns them into PHP commands.

                        Yes, I could find it. No, I couldn't fix it without about a days worth of Googling for the correct way to parse / implement it on the command line and massaging it all together.

                        That is why I would just submit a bug in the issue tracker, the devs know far better than me off hand, what script specifically processes or is supposed to process these options, and the proper way to code in the commands to implement the options properly again.

                        For me, it's 2:35am and time to relax until tomorrow ;-)

                        1 Reply Last reply Reply Quote 0
                        • K
                          kejianshi
                          last edited by Jul 20, 2013, 6:40 AM

                          I'll check and see what differences I see after another beer (-:  Then rest.

                          1 Reply Last reply Reply Quote 0
                          • K
                            ky41083 Banned
                            last edited by Jul 20, 2013, 7:40 AM Jul 20, 2013, 7:38 AM

                            According to rules.debug, after applying a Maximum new connections / per second(s) value of 704 per 5 seconds it, nor any of the other settings under the "Advanced Options" section appear, the rule remains as follows:

                            pass  in  quick  on $LAN inet from 192.168.1.0/24 to ! $PrivateIPv4  label "USER_RULE: Session Limit Internet Traffic"

                            Update: Running - pfctl -sa | grep "704" - at the command line returns absolutely nothing.

                            1 Reply Last reply Reply Quote 0
                            • K
                              kejianshi
                              last edited by Jul 20, 2013, 11:59 AM

                              That is weird.  Must be broken.

                              1 Reply Last reply Reply Quote 0
                              • P
                                phil.davis
                                last edited by Jul 20, 2013, 12:25 PM

                                filter.inc

                                	$noadvoptions = false;
                                	if(isset($rule['statetype']) && $rule['statetype'] <> "") {
                                		switch($rule['statetype']) {
                                			case "none":
                                				$noadvoptions = true;
                                				$aline['flags'] .= " no state ";
                                				break;
                                
                                

                                If the state type (another advanced rule option) is set to "none" then the "Advanced Options" settings on the rule do not apply. That is the only obvious way I see that the code can bypass putting max-src-states and similar into the pf rule.

                                As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
                                If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

                                1 Reply Last reply Reply Quote 0
                                • K
                                  kejianshi
                                  last edited by Jul 20, 2013, 1:16 PM Jul 20, 2013, 1:08 PM

                                  I've tried this last night with beer and today without and got the same results.

                                  So, this time I'm only applying 853 connections / 1 second then doing a filter reload.
                                  Checked to make  sure its still "keep state"

                                  pfctl -sa | grep "853"
                                  pass in quick on nfe0 reply-to (nfe0 78.22.113.1) inet proto tcp from any to 192.168.13.1 port = 49132 flags S/SA keep state (source-track rule, max-src-conn-rate 853/1, overload <virusprot>flush global, src.track 1) label "USER_RULE: NAT 49132 Stunnel to Foscam"

                                  It is making changes to PF on my version.  If same thing in 2.1 doesn't end up in PF rules it must be broken.
                                  Mine is 2.03</virusprot>

                                  1 Reply Last reply Reply Quote 0
                                  • K
                                    ky41083 Banned
                                    last edited by Jul 21, 2013, 2:47 AM Jul 21, 2013, 2:39 AM

                                    Ok, so just for the record, you're on 2.0.3-RELEASE? and it's working (you're getting something anyways).

                                    I'm on 2.1-RC0 (i386) built on Thu Jul 18 21:59:09 EDT 2013 (pfSense-2.1-RC0-2g-i386-nanobsd_vga-upgrade-20130718-2159.img.gz)

                                    @phil.davis:

                                    filter.inc

                                    	$noadvoptions = false;
                                    	if(isset($rule['statetype']) && $rule['statetype'] <> "") {
                                    		switch($rule['statetype']) {
                                    			case "none":
                                    				$noadvoptions = true;
                                    				$aline['flags'] .= " no state ";
                                    				break;
                                    
                                    

                                    If the state type (another advanced rule option) is set to "none" then the "Advanced Options" settings on the rule do not apply. That is the only obvious way I see that the code can bypass putting max-src-states and similar into the pf rule.

                                    The state type on all of my rules in question (and the rest to be honest) are all set to the default value of "keep state", so by that function all of the advanced options I have set should be applied on the backend, and they are not :P

                                    So, bug submittal time ;)

                                    1 Reply Last reply Reply Quote 0
                                    • P
                                      phil.davis
                                      last edited by Jul 21, 2013, 3:35 AM

                                      I looked further up the code block:

                                      	if (($rule['protocol'] == "tcp") && ($type == "pass")) {
                                      ... do advanced sate-related settings
                                      

                                      So this is only actioned for rules that are for protocol TCP.
                                      If protocol is "all" it won't put the advanced settings in.
                                      I guess that is reasonable, states are only TCP things, but for protocol "all" it could first write a TCP rule with the advanced settings then another generic rule for everything else (UDP, ICMP…). Or at the GUI could give an error message when saving, telling you that these advanced settings are only for protocol TCP.

                                      As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
                                      If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

                                      1 Reply Last reply Reply Quote 0
                                      • K
                                        ky41083 Banned
                                        last edited by Jul 21, 2013, 3:39 AM

                                        Submitted to Redmine, can follow up at:

                                        https://redmine.pfsense.org/issues/3098

                                        1 Reply Last reply Reply Quote 0
                                        • K
                                          ky41083 Banned
                                          last edited by Jul 21, 2013, 3:49 AM Jul 21, 2013, 3:40 AM

                                          @phil.davis:

                                          I looked further up the code block:

                                          	if (($rule['protocol'] == "tcp") && ($type == "pass")) {
                                          ... do advanced sate-related settings
                                          

                                          So this is only actioned for rules that are for protocol TCP.
                                          If protocol is "all" it won't put the advanced settings in.
                                          I guess that is reasonable, states are only TCP things, but for protocol "all" it could first write a TCP rule with the advanced settings then another generic rule for everything else (UDP, ICMP…). Or at the GUI could give an error message when saving, telling you that these advanced settings are only for protocol TCP.

                                          Ahh that's starting to make sense ;D Sweet, and I agree, it should at LEAST be notated that they will ONLY apply to TCP rules. Going to test now…

                                          Update: These options should be applied on the backend for UDP also at the very least, and honestly for any protocol that can make a state table entry. Outgoing UDP can cripple a router, in the session table sense, in a matter of seconds…. we need more control here, and I believe pf is more than capable of this.

                                          1 Reply Last reply Reply Quote 0
                                          24 out of 31
                                          • First post
                                            24/31
                                            Last post
                                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                                            This community forum collects and processes your personal information.
                                            consent.not_received