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

    Firewall rules based on interface

    Scheduled Pinned Locked Moved Firewalling
    20 Posts 7 Posters 7.9k 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.
    • F
      fwadmin
      last edited by

      I don't think i have been very clear about the problem.  I want to create a firewall rule similar to what I can do with IPTABLES in a chain rule i.e.

      -A FORWARD -i PUBLIC1 -j OUTBOUND_ALL
      -A OUTBOUND_ALL -o OUTSIDE -m state –state NEW -j ACCEPT

      There are no references to subnets or IP's.  Simply allowing traffic in one interface and out another.  One side of the rule depends on the other.  That might be the caveat that is creating confusion.  The first rule doesn't allow anything by itself.  Though it defines what is allowed inbound on the PUBLIC1 interface, nothing is allowed without the second line.

      With the -i switch and possibly utilizing the anchor feature of pfctl, I hoping to do the same with pfsense.

      1 Reply Last reply Reply Quote 0
      • M
        Metu69salemi
        last edited by

        if you want to allow everything why to have osi layer 4 device, why don't simply use osi layer 3 three device(router) and there allow routing between everything

        1 Reply Last reply Reply Quote 0
        • F
          fwadmin
          last edited by

          Most of our firewalls have 10 interfaces.  We typically allow everything going out the Outside interface:

          Source=any Destination=any Protocol=any In Interface=any Out Interface=Outside

          This takes care of Internet access without giving access to any internal services.  Then i have intra containment zone rules such as:

          Source=any Destination=any Protocol=CIFS,DNS, etc In Interface=InterfaceY Out Interface=InterfaceZ

          The later rule is not the challenge here.  It is how do I give the nine containment zones full internet access without giving them access to internal services.  Better stated, without a series of deny rules, how would i do this.  This is a simple rule set:

          All through the Outside interface for all
          Containment Zone One to Containment Zone Two for X procotols
          Containment Zone One to Containment Zone Three for X procotols
          Containment Zone Four to Containment Zone Five for X procotols
          Deny All

          Otherwise the rule set would double:

          Deny Containment Zone One to Containment Zone Two for X procotols
          Deny Containment Zone One to Containment Zone Three for X procotols
          Deny Containment Zone Four to Containment Zone Five for X procotols
          Containment Zone One to all for all
          Containment Zone Two to all for all
          Containment Zone Four to all for all
          Deny all

          Not to mention we allow fewer protocols than we deny making the firewall configuration more complicated.

          1 Reply Last reply Reply Quote 0
          • M
            Metu69salemi
            last edited by

            You could simplify rulesets by using aliases. but remember you can't mix alias types in one alias(example: IP's and Port numbers). Then configuration might be easier to read and more comfortable to use

            1 Reply Last reply Reply Quote 0
            • X
              XIII
              last edited by

              You might be able to do what you want but pfSense is designed to be administered through the gui. To do it the way you want I believe you would have to do it via CLI.

              -Chris Stutzman
              Sys0:2.0.1: AMD Sempron 140 @2.7 1024M RAM 100GHD
              Sys1:2.0.1: Intel P4 @2.66 1024M RAM 40GHD
              freedns.afraid.org - Free DNS dynamic DNS subdomain and domain hosting.
              Check out the pfSense Wiki

              1 Reply Last reply Reply Quote 0
              • C
                cmb
                last edited by

                You cannot just specify interfaces in rules (in the GUI or the underlying system), using subnets, aliases or interface groups (likely a combination) can do what you want by using IP subnets rather than interfaces.

                1 Reply Last reply Reply Quote 0
                • jimpJ
                  jimp Rebel Alliance Developer Netgate
                  last edited by

                  On 2.0 you can use floating rules and/or interface groups to get closer to what you want, but with traditional rules you do need to block inbound on the interfaces going to every other network you don't want them to access. By using aliases, you don't really need X number of individual rules, you could do it with only a couple of them.

                  Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                  Need help fast? Netgate Global Support!

                  Do not Chat/PM for help!

                  1 Reply Last reply Reply Quote 0
                  • M
                    MikeN
                    last edited by

                    fwadmin: Did you ever manage to find a good solution to this?

                    It's really a problem I can't reliably filter traffic based on source/destination interfaces. If I allow traffic to 'the internet' (which I can't specify with an IP range), I immediately allow traffic to all other interfaces and not just the gateway interface…..

                    1 Reply Last reply Reply Quote 0
                    • C
                      cmb
                      last edited by

                      @MikeN:

                      It's really a problem I can't reliably filter traffic based on source/destination interfaces. If I allow traffic to 'the internet' (which I can't specify with an IP range), I immediately allow traffic to all other interfaces and not just the gateway interface…..

                      Easy, just block or reject what you don't want to permit (most commonly with an alias of local and VPN-attached networks, if not all of RFC1918) above allowing destination "any" for required Internet traffic.

                      1 Reply Last reply Reply Quote 0
                      • M
                        MikeN
                        last edited by

                        @cmb:

                        @MikeN:

                        It's really a problem I can't reliably filter traffic based on source/destination interfaces. If I allow traffic to 'the internet' (which I can't specify with an IP range), I immediately allow traffic to all other interfaces and not just the gateway interface…..

                        Easy, just block or reject what you don't want to permit (most commonly with an alias of local and VPN-attached networks, if not all of RFC1918) above allowing destination "any" for required Internet traffic.

                        That is an option, but:

                        • It's error prone. If in the future new IP ranges get added to interfaces, I will have to make sure that these get blocked too. I rather have something closed/secure by default, instead of the other way around.
                        • It's quite some work if you got multiple interfaces. I still have to look into the floating rules (running 2.0-rc3 here), and where they're added in the pf ruleset, so maybe floating rules can resolve this issue…
                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.