Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Register
    • Login
    Introducing Netgate Nexus: Multi-Instance Management at Your Fingertips.

    Regex - How to block subdomains?

    Scheduled Pinned Locked Moved pfBlockerNG
    4 Posts 2 Posters 2.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.
    • CreationGuyC
      CreationGuy
      last edited by

      I'm trying to block a domain and all of it's subdomains, I've tried a few different methods and none seem to be working.

      \.google\.
      

      With that, I can't get to www.google.com but can get to subdomains.

      (\.|^)google\.com$
      

      Same results as above.

      (^|\.)google\.com$
      

      Same results as above.

      P 1 Reply Last reply
      Reply Quote 0
      • P
        Patch @CreationGuy
        last edited by Patch

        @creationguy said in Regex - How to block subdomains?:

        I'm trying to block a domain and all of it's subdomains,

        I suspect what you want to do is hard at the firewall level.
        You could try blocking Googles ASN in pfblockerNG then white list what you want to allow. Unfortunately Google frequently changes the IP address each domain name resolves to, so to make this solution work, pfsense needs aliases with history (which I don't think are currently supported).

        Alternatively blocking it at the DNS may be possible.

        CreationGuyC 1 Reply Last reply
        Reply Quote 0
        • CreationGuyC
          CreationGuy @Patch
          last edited by

          Google was just an example, not the real domain. Wouldn't this be best accomplished within the pfBlocker package? That's what I'm trying to do.

          It works in Pihole use the 1st regex, but not here.

          CreationGuyC 1 Reply Last reply
          Reply Quote 0
          • CreationGuyC
            CreationGuy @CreationGuy
            last edited by CreationGuy

            Update:

            (^|\.)domain\.com$
            

            Blocks the domain and subdomain... I just didn't clear my DNS cache on device. So far, it is working.

            1 Reply Last reply
            Reply Quote 1

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            Copyright 2026 Rubicon Communications LLC (Netgate). All rights reserved.
            Privacy Policy · Cookie Policy