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

Regex - How to block subdomains?

Scheduled Pinned Locked Moved pfBlockerNG
4 Posts 2 Posters 1.1k 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.
  • C
    CreationGuy
    last edited by Aug 14, 2022, 3:55 AM

    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 Aug 14, 2022, 4:13 AM Reply Quote 0
    • P
      Patch @CreationGuy
      last edited by Patch Aug 14, 2022, 4:13 AM Aug 14, 2022, 4:13 AM

      @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.

      C 1 Reply Last reply Aug 14, 2022, 4:15 AM Reply Quote 0
      • C
        CreationGuy @Patch
        last edited by Aug 14, 2022, 4:15 AM

        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.

        C 1 Reply Last reply Aug 16, 2022, 4:04 AM Reply Quote 0
        • C
          CreationGuy @CreationGuy
          last edited by CreationGuy Aug 16, 2022, 4:05 AM Aug 16, 2022, 4:04 AM

          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
          4 out of 4
          • First post
            4/4
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
            This community forum collects and processes your personal information.
            consent.not_received