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

    Geoblocking the world except for home

    Scheduled Pinned Locked Moved pfBlockerNG
    geolocationrulesdnsblgeoblocking
    11 Posts 4 Posters 1.8k 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.
    • S
      SteveITS Galactic Empire @TrigglePuff
      last edited by

      @trigglepuff Firewall rules are processed in order, as a packet arrives on an interface. Thus WAN rules apply to inbound from the Internet. LAN rules apply to connections out to the Internet. So if you're trying to connect out, use LAN rules like:

      allow from LAN Net to (alias) port 443
      reject from LAN Net to * port 443
      (repeat with port 80 or others)
      (default) allow from LAN Net to *

      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!

      T 1 Reply Last reply Reply Quote 0
      • T
        TrigglePuff @SteveITS
        last edited by

        @steveits Thanks so much Steve. If my alias is countries that to which I want to allow outbound connections, am I doing this correctly in choosing an inverse match?

        If so, I am thinking my next rule is to block everything outbound NOT headed to these countries. :) :)

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

          @trigglepuff Inverting can be a bit tricky so I'd avoid it if you're getting started with pfSense. It's usually easier to follow the rules without those sort of things.

          The two rules I posted above will allow HTTPS out to your alias and block the rest. Can you post the LAN rules you have now that aren't working?

          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!

          T 1 Reply Last reply Reply Quote 0
          • T
            TrigglePuff @SteveITS
            last edited by

            @steveits Hi Steve. I created a GEOIP-based alias named pfB_SAFECNS_v4, then set it up to allow all LAN packets out. I then tried to block by inverting the match, so that if packets aren’t headed from the LAN to a safe country, they get stopped. But the latter seems to still let stuff through—which I guess could be a function of where the host’s CDN is, etc.

            I also noticed that whatever my spyware is that is calling home to Barbados, it’s using some of the really esoteric ports and moves around. But when I look up the destination addresses, they’re all clustered in the same area in Barbados. And I work at a high-risk job, so I don’t like things that call home without asking me first :)

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

              @trigglepuff Note if there are open states when you add rules, pfSense will honor the state and continue to allow the traffic.
              https://docs.netgate.com/pfsense/en/latest/troubleshooting/firewall.html#check-the-state-table
              "If the rule is a block rule and there is a state table entry, the open connection will not be cut off. To see an immediate effect from a new block rule, the states must be reset."

              If you do something like
              reject from LAN Net to (!alias)
              ...I would probably expect that to block the pfSense IPs since they are not in the alias. One can work around that by adding an allow rule above it.

              If you create a rule to reject from LAN Net to Barbados and log it you can find the IPs connecting out.

              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
              • G
                Gblenn
                last edited by

                Am I not understanding the idea here... It seems to me that it's as simple as going into pfBlocker > IP > GeoIP and then under each region simply mark all the countries that should be blocked. Then select outbound, inbound or both, for each region...
                If it's just a few countries that should be allowed, do a select All and then Ctrl click the few you want to deselect...
                All the rules will be created automatically after that...

                NogBadTheBadN 1 Reply Last reply Reply Quote 0
                • NogBadTheBadN
                  NogBadTheBad @Gblenn
                  last edited by NogBadTheBad

                  @gblenn IMO its much better to create an an alias rather than use the GeoIP tab and use it in a firewall rule:-

                  Screenshot 2023-02-03 at 14.49.41.png

                  Screenshot 2023-02-03 at 14.50.13.png

                  Andy

                  1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

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

                    @nogbadthebad Since you showed "alias permit" just be aware that reportedly de-dupes across other permit or deny lists. There was a thread last year sometime where someone pointed out IPs were being removed. Alias Native will leave the lists unchanged.

                    @Gblenn You're not wrong. :) Aliases are a bit more flexible, for instance we can allow traffic to certain IPs, then block the country. pfB deny rules insert together, by default at the top of the list of rules (per "Firewall 'Auto' Rule Order").

                    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!

                    G NogBadTheBadN 2 Replies Last reply Reply Quote 1
                    • G
                      Gblenn @SteveITS
                      last edited by Gblenn

                      @steveits I think I have to dig into Aliases a bit more. Using it for simple stuff like ports and device IP's of course but it seems like there is a lot to learn...

                      1 Reply Last reply Reply Quote 0
                      • NogBadTheBadN
                        NogBadTheBad @SteveITS
                        last edited by

                        @steveits said in Geoblocking the world except for home:

                        @nogbadthebad Since you showed "alias permit" just be aware that reportedly de-dupes across other permit or deny lists. There was a thread last year sometime where someone pointed out IPs were being removed. Alias Native will leave the lists unchanged.

                        Cheers I've changed them :)

                        Andy

                        1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

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