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

    Block subdomain (cname)

    Scheduled Pinned Locked Moved General pfSense Questions
    8 Posts 3 Posters 1.2k 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
      dridhas
      last edited by

      Hello all,

      good day and happy friday!!

      Just want to ask if pfsense is capable of blocking a subdomain (cname) from being accessible from outside a country?

      basically something like this: "block if cname is sub.domain.com AND outside US"

      i know i can do a whole country block, but unsure how can this be applied.

      Thanks in advance for any advise!

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

        @dridhas You can block traffic from a country to an IP address. If the IP isn't unique then I think you'll need something like squid to proxy the incoming web request and handle the block.

        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!

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

          @steveit this is the scenario:
          ive got a website and the traffic should only come from US.
          the server that hosts the website has a static public ipaddress.

          So if i understand correctly, i can block for example, Canada to be able to get to the website on the static ip address, correct?

          V 1 Reply Last reply Reply Quote 0
          • V
            viragomann @dridhas
            last edited by

            @dridhas
            You can install and use the pfBlockerNG package for that.

            If you want to allow only one or a view countries, best practice is to let pfBlocker generate only aliases. You can use these after in pass rules at source for allowing access to your server.

            D 2 Replies Last reply Reply Quote 0
            • D
              dridhas @viragomann
              last edited by

              @viragomann thank you for the suggestions.

              this is what i did
              15ef62e0-9a5a-4458-a53d-130152cc185a-image.png

              inside the North America, i highlighted the desired countries to block and then use these settings:
              a227392a-81d8-4467-9549-bc276e1ce954-image.png .

              On the firewall rules i can see this:
              8a4ea8b3-516e-416d-8483-5f3e0c114473-image.png

              i used a VPN to emulate the country, and the website did not load... ๐Ÿ˜ƒ

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

                @viragomann next step is to block just the subdomain so i can leave some other services accessible to outside US.

                V S 2 Replies Last reply Reply Quote 0
                • V
                  viragomann @dridhas
                  last edited by

                  @dridhas
                  pfSense can out of the box only filter traffic on the base of IP and port.
                  So if you have multiple services on the same IP and port, pfSense cannot differ them. This can only be done by a proxy package as already suggested.

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

                    @dridhas Block from North America to that IP address as the destination.

                    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 0
                    • First post
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.