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

    Order of FW Rules...

    Scheduled Pinned Locked Moved Firewalling
    12 Posts 5 Posters 789 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.
    • D
      doni49
      last edited by doni49

      It has always been my understanding that until you add firewall rules to an interface allowing a specified type of traffic, all traffic on that interface is blocked. So what is the purpose of a BLOCK rule?

      When a device is on my IoT network, I don't want it to have access to anything on any of the other VLANs (or the default LAN).

      Following is a screenshot of the rules I have defined on my IoT Firewall.

      They allow access to the DNS on the firewall and to use the gateway for internet access (or at least that is what is supposed to happen). But when I'm connected to this VLAN, I'm still able to access devices in the default LAN: 10.1.1.1 (the pfSense Router), 10.1.1.2 (the ProxMox machine that hosts pfSense and Home Assistant) and 10.1.1.3 (my managed switch). Shouldn't the fact that I haven't created a rule to allow that activity be enough to prevent it? I previously tried making a rule that blocks any traffic destined for any network other than IoT. If I put that at the top of the list, I couldn't access ANYTHING while connected to IoT -- internet or otherwise. If I put that rule at the bottom of the list, there was no change -- I could access anything including the default LAN.

      93c0f3cf-2575-4e86-9c0f-0080a1f7ded9-image.png

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

        @doni49 Do you have any floating rules?

        Your rule is any any, but your forcing out your wan gateway. If the gateway is down that rule could be created without the gateway setting depending on your setting.

        Rules are evaluated top down, first rule to trigger wins, no other rules are evaluated - but with that policy route - there are couple of settings that come to mind that could maybe cause what your seeing

        things.jpg

        Floating tab is evaluated first - so if you have stuff in there it could supersede what rules you have on the interface. Also states that have been created would still work until the state is gone, or killed, etc.

        Also you have some sort of VM setup - that could be have something to do with it, maybe you don't have your networks actually isolated at layer 2?

        But normally those rules would no allow this iot network to talk to your other networks because your shoving it out your wan gateway. But since it is an any rule, and if your wan gateway could get to your lan?

        It is always best to be explicit in your rules and block what you don't want to allow.. before you allow what you want, if you want to have a locked down vlan/network that can not talk to your other networks, or pfsense gui, etc.. Here is an example of such a locked down network.

        locked.jpg

        This "test" network of mine can ping pfsense test IP, can ask pfsense for dns, and ntp and can talk to my pihole on 192.168.3.10, but then it can not talk to any other firewall IP.. Nor can it get to any other rfc1918 network - my other networks.. But then it is allowed to talk to the internet.

        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 24.11 | Lab VMs 2.8, 24.11

        D 2 Replies Last reply Reply Quote 0
        • D
          doni49 @johnpoz
          last edited by

          @johnpoz
          Thanks for the reply. I'll respond to a couple of things you noted and take a closer look at the rest of your reply -- probably in the morning.

          I have no floating rules. I've read that they can be more of a security risk than anything so I've avoided them.

          I have Proxmox installed with two VMs installed: Home Assistant (configured in proxmox to use VLAN 200 -- I'm guessing that's what you were asking about on segregating the VMs) and pfSense. That is not assigned a VLAN tag it is my understanding that leaving it without a VLAN tag automatically puts it in the default LAN and that's where it want it to live.

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

            @johnpoz
            I decided to just look at it tonight.

            I'm confident the gateway wasn't down when this was happening -- I was streaming youtube on my Roku at the time of testing this and it uses the same gateway.

            But I changed up the rules to see if I could improve things. With this set of rules, my phone when connected to IoT, is able to access both the internet and home assistant (10.20.0.2). But I was still able to access pfSense's admin pages which would be 10.1.1.1 and should be covered by the RFC1918 blocking rule.

            I liked the idea of including a rule to allow NTP access so I added that.

            af667246-a471-4b00-b51c-b0b3c6ed2dbf-image.png

            e1db29da-6f23-491a-95d6-f5441411f36d-image.png
            Edit: I noticed that the Alias says 10.0.0.0/32. I changed that to 10.0.0.0/8, saved it and then was still able to access 10.1.1.1 from my phone that is connected to IoT.

            This is from the configuration page for the IoT Interface.b4a7a9b2-cf79-4c1b-affe-560bcc275ba6-image.png

            I started accumulating smart devices in the last 9 months or so and I'm already up to 90. So I wanted to build in room for growth -- yes, I know /22 will allow for alot of devices.

            D 1 Reply Last reply Reply Quote 0
            • D
              doni49 @doni49
              last edited by

              @johnpoz

              I now suspect that maybe I was testing it too soon after updating the rules. I just tried it again and was unable to access 10.1.1.1.

              Thanks!

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

                @doni49 As I mentioned states would allow traffic.. States are evaluated before rules. If there is a state that allows the traffic, it would be used before any rule that would prevent the creation of the state in the first place.

                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 24.11 | Lab VMs 2.8, 24.11

                D 1 Reply Last reply Reply Quote 1
                • M
                  mer
                  last edited by

                  One thing I like to do:
                  Diagnostics, Command Prompt and enter:
                  pfctl -sr

                  That will give you all the rules in the order and expanded. It helps me when I can't remember "which is applied first, floating interface or something else".

                  As for a block rule, if it's near/at the top of the list then yes it would be evaluated first, evaluation doesn't always mean applied. As @johnpoz says state would override application.

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

                    @johnpoz said in Order of FW Rules...:

                    @doni49 States are evaluated before rules.

                    I guess that's where my confusion lies. I'll have to read up on "states".

                    D johnpozJ S 3 Replies Last reply Reply Quote 0
                    • D
                      doni49 @doni49
                      last edited by doni49

                      @johnpoz

                      BTW... I suspect that I wasn't waiting long enough after saving my rules edits before testing for access. Because even though I was still able to access 10.1.1.1 from an IoT device before I went to bed, that is no longer the case.

                      It all seems to be working as desired this morning.

                      J 1 Reply Last reply Reply Quote 0
                      • J
                        Jarhead @doni49
                        last edited by

                        @doni49 said in Order of FW Rules...:

                        @johnpoz

                        BTW... I suspect that I wasn't waiting long enough after saving my rules edits before testing for access. Because even though I was still able to access 10.1.1.1 from an IoT device before I went to bed, that is no longer the case.

                        It all seems to be working as desired this morning.

                        That's exactly what John said. If there's an existing state, traffic will pass.
                        If you are constantly pinging a device, and then add a rule to block ping, it'll still constantly ping until you stop pinging, and then the existing state times out.
                        So if you create a new new, it may help to kill all states on that interface if you don't want to wait for the timeout.

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

                          @doni49 said in Order of FW Rules...:

                          I'll have to read up on "states".

                          Yeah I would recommend that, since pfsense is a stateful firewall.. Pretty handy to understand what a state is ;)

                          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 24.11 | Lab VMs 2.8, 24.11

                          1 Reply Last reply Reply Quote 1
                          • S
                            SteveITS Galactic Empire @doni49
                            last edited by

                            @doni49 said in Order of FW Rules...:

                            @johnpoz said in Order of FW Rules...:

                            @doni49 States are evaluated before rules.

                            I guess that's where my confusion lies. I'll have to read up on "states".

                            See https://docs.netgate.com/pfsense/en/latest/troubleshooting/firewall.html#new-rules-are-not-applied

                            Pre-2.7.2/23.09: 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 restart, or more depending on packages and device speed.
                            Upvote 👍 helpful posts!

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