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

    How to block all but a few outbound ports for alias

    Scheduled Pinned Locked Moved Firewalling
    11 Posts 4 Posters 1.0k Views 4 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.
    • bepoB Offline
      bepo @chrisbo
      last edited by

      @chrisbo you could create an alias containing all ip cam ip addresses. Then use this alias in a firewall rule to allow all allowed ports (again, create an alias containing all ports). Below of this rule you create a rule blocking any for the ip cam alias.

      Rules are processed from top to bottom.

      Please use the thumbs up button if you received a helpful advice. Thank you!

      1 Reply Last reply Reply Quote 0
      • C Offline
        chrisbo
        last edited by

        Thank you for your reply.

        That's the way I thought it should be but whenever I enable the rule to block any for the IP cam alias, all IP cam traffic is blocked. Just above it, I have an allow rule for the same IP alias which permits to any destination using a port alias containing TCP 25, 53, 123.

        For testing I'm using a laptop with an IP in the scope used for my IP cams. With the deny rule off I can browse on TCP 80 or 443 and use nslookup but when the deny rule is enabled the laptop has no outbound access.

        I also created another permit rule only for the laptop IP and only port 25, which is placed just above the deny rule but still everything is blocked.

        Seems to be ignoring my permit rules before the deny rule.

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

          post your rules and we can discuss.. Rules are evaluated top down, first rule to trigger wins and no other rules are evaluated.

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

          C 1 Reply Last reply Reply Quote 0
          • C Offline
            chrisbo @johnpoz
            last edited by

            @johnpoz Thanks, below are the two firewall rules which I expected to allow TCP 53 then block all. The test laptop is 192.168.2.248, the alias IP_Cams is 192.168.2.245 - 254. Is that enough info or do I need to post more like full rules and alias?

            <rule>
            <id></id>
            <tracker>1548431689</tracker>
            <type>pass</type>
            <interface>lan</interface>
            <ipprotocol>inet</ipprotocol>
            <tag></tag>
            <tagged></tagged>
            <max></max>
            <max-src-nodes></max-src-nodes>
            <max-src-conn></max-src-conn>
            <max-src-states></max-src-states>
            <statetimeout></statetimeout>
            <statetype><![CDATA[keep state]]></statetype>
            <os></os>
            <protocol>tcp</protocol>
            <source>
            <address>192.168.2.248</address>
            </source>
            <destination>
            <any></any>
            <port>53</port>
            </destination>
            <log></log>
            <descr></descr>
            <updated>
            <time>1548431689</time>
            <username>admin@192.168.2.22 (Local Database)</username>
            </updated>
            <created>
            <time>1548431689</time>
            <username>admin@192.168.2.22 (Local Database)</username>
            </created>
            </rule>
            <rule>
            <id></id>
            <tracker>1548402225</tracker>
            <type>reject</type>
            <interface>lan</interface>
            <ipprotocol>inet</ipprotocol>
            <tag></tag>
            <tagged></tagged>
            <max></max>
            <max-src-nodes></max-src-nodes>
            <max-src-conn></max-src-conn>
            <max-src-states></max-src-states>
            <statetimeout></statetimeout>
            <statetype><![CDATA[keep state]]></statetype>
            <os></os>
            <source>
            <address>IP_Cams</address>
            </source>
            <destination>
            <any></any>
            </destination>
            <descr></descr>
            <created>
            <time>1548402225</time>
            <username>admin@192.168.2.22 (Local Database)</username>
            </created>
            <updated>
            <time>1548420963</time>
            <username>admin@192.168.2.22 (Local Database)</username>
            </updated>
            </rule>

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

              Dude post up screenshot of your rules.. Need to SEE ALL rules on your interface so can see the order you have them in, etc..

              example here is one of my vlans
              0_1548439803811_example.png

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

              C 1 Reply Last reply Reply Quote 0
              • C Offline
                chrisbo @johnpoz
                last edited by

                @johnpoz Thanks again, here it is:

                0_1548440111339_pfSense FW Rules.JPG

                1 Reply Last reply Reply Quote 0
                • KOMK Offline
                  KOM
                  last edited by

                  You need UDP for DNS, not just TCP.

                  C 1 Reply Last reply Reply Quote 0
                  • C Offline
                    chrisbo @KOM
                    last edited by

                    @kom OMG, I should know that.... always forgetting.... Thanks so much guys for your time and help!!

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

                      What is this IP 192.168.2.248? Why are you only allowing it to talk dns on tcp?

                      I don't see any rules for the 25 and 123 you mentioned. Also you are blocking all IP_cams to anywhere. Other than your antilockout.. Keep in mind when you create a block rule that you have to make sure you kill any active states - once a state is created it will be used to allow traffic. So you either have to wait for the state to expire or reset it for block rules to work, etc.

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

                      C 1 Reply Last reply Reply Quote 0
                      • C Offline
                        chrisbo @johnpoz
                        last edited by

                        @johnpoz

                        I did something stupid, I based all my testing using nslookup on a laptop (192.168.2.248) but did not include UDP 53 in the pass rule.

                        To simplify the rules for myself I disabled the rule which included the IP alias for TCP 25, 53 and 123 and I created a new rule for only TCP 53 for 192.168.2.248.

                        Now I have edited the allow rule for TCP/UDP and things work as expected.

                        0_1548442856717_89ff2cf0-98a6-45b6-b86b-34b4ce104254-image.png

                        Thanks very much for the info on active states and for helping with my mistake.

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