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

    block custom domains in pfblocker

    Scheduled Pinned Locked Moved General pfSense Questions
    39 Posts 12 Posters 16.7k 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.
    • T
      TopperTom @johnpoz
      last edited by

      @johnpoz
      Thanks, John. I've been around this game for a LONG time and everytime I have to learn a new firewall, there always seems to be some head-banging that I have to go through.

      I agree that editing a conf file will not work as they will get overwritten. So I'm looking at using the custom option box. So first, the only custom option I find is under "DNS Resolver/General Settings" will lines suggested:
      Capture2.JPG

      But that then produces this:
      Capture.JPG

      So perhaps I don't know where the "control box of unbound" is as was suggested earlier. Am I even in the right neighborhood?

      Thanks for your patience.

      O 1 Reply Last reply Reply Quote 0
      • G
        GregBinSD
        last edited by

        Tom, try this:

        server:
        local-zone: "facebook.com" redirect
        local-data: "facebook.com A 127.0.0.1"
        include: /var/unbound/pfb_dnsbl.*conf

        T 1 Reply Last reply Reply Quote 0
        • T
          TopperTom @GregBinSD
          last edited by

          @GregBinSD
          Same error.....

          1 Reply Last reply Reply Quote 0
          • G
            GregBinSD
            last edited by

            Sorry, Tom. Try one more thing.

            Looking above a little, johnpoz pasted just these lines into the Customs options box, leaving out the pfblocker line:

            server:
            local-zone: "facebook.com" redirect
            local-data: "facebook.com A 127.0.0.1"

            So, clear out the Customs options box and paste in the 3 lines above, like johnpoz did.

            BTW, at Windows cmd prompt, clear the DNS cache by typing:
            ipconfig /flushdns

            ...and clear your browser's cache of history and files, as well, before testing your results.

            Greg

            T 1 Reply Last reply Reply Quote 0
            • T
              TopperTom @GregBinSD
              last edited by

              @GregBinSD

              But isn't the pfblocker line responsible for loading the blocklist feeds?

              1 Reply Last reply Reply Quote 0
              • G
                GregBinSD
                last edited by

                Tom, johnpoz knows for sure, but from what I have gathered, the DNS used by pfSense is called "unbound", and it can be seen running in the background if you go to Status/Services. Unbound can read those 3 lines without the help of pfBlockerNG. In fact, I am experimenting with a TLS encrypted DNS service, without using pfBlockerNG. The developer had me put 8 lines into the Custom options box, along with setting some parameters giving me an account on his web interface. None of those lines reference pfb.

                1 Reply Last reply Reply Quote 0
                • stephenw10S
                  stephenw10 Netgate Administrator
                  last edited by

                  I would add them through pfBlocker as I outlined above. But pfBlocker just adds it's own additional config there so you can add it manually to Unbound if you want.

                  If the pfb_dnsbl include file already has a zone defined for facebook.com you might be conflicting. Try adding something completely different there.

                  Steve

                  1 Reply Last reply Reply Quote 0
                  • O
                    OlofTheBald @TopperTom
                    last edited by

                    @TopperTom Hey Tom, I made an account just to answer your question here, as you're very very close to having this correct.

                    You can put the include for your conf file at the bottom of the box and any server includes you need at the top. I run this exact thing on my box while I'm experimenting with blocking Youtube ads. Here's what my custom options look like:

                    server:
                    local-zone: "manifest.googlevideo.com" redirect
                    local-data: "manifest.googlevideo.com A 10.10.10.1"
                    include: /var/unbound/pfb_dnsbl.*conf
                    

                    I hope this helps relieve the frustrations you've had with this so far.

                    1 Reply Last reply Reply Quote 0
                    • stephenw10S
                      stephenw10 Netgate Administrator
                      last edited by stephenw10

                      Yes, that should work as long as manifest.googlevideo.com is not defined as a local-zone in pfb_dnsbl.conf already. I think that was the problem previously. Once we removed the two server entries.

                      Steve

                      O 1 Reply Last reply Reply Quote 0
                      • O
                        OlofTheBald @stephenw10
                        last edited by

                        @stephenw10 said in block custom domains in pfblocker:

                        Yes, that should work as long as manifest.googlevideo.com is not defined as a local-zone in pfb_dnsbl.conf already. I thing that was the problem previously. Once we removed the two server entries.

                        Steve

                        Ah, that makes sense. After reading back through the thread again, I see that GregBinSD made the same recommendation that I did and Tom still had problems with that. In this use case, I'd have to echo what others have already said about just making a custom feed and putting any entries needed in there.

                        1 Reply Last reply Reply Quote 1
                        • S SteveITS referenced this topic on
                        • LPD7L LPD7 referenced this topic on
                        • S
                          SteveITS Galactic Empire @fadygh
                          last edited by

                          This is an old topic but it's the second search result. In the current (ex-devel, now same as -devel) version of pfBlockerNG it is under:

                          • Firewall/pfBlockerNG/DNSBL/DNSBL Groups
                          • edit an existing group or create a new group
                          • expand DNSBL Custom_List towards the bottom (below Advanced Tuneables)
                          • add hostnames to the large text box

                          Save. If you created a new group remember to set Action=Unbound (instead of Disabled). Run a pfB Update.

                          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!

                          O 1 Reply Last reply Reply Quote 0
                          • O
                            orangehand @SteveITS
                            last edited by orangehand

                            @SteveITS I'm trying to use StevenBlack's list. How would I link to it's online location as opposed to pasting in a vast list of url's?

                            I pasted https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/porn/hosts into the source filed but it complains it needs a header - any idea what it is aksing for?
                            The entries in the list are in the format of

                            0.0.0.0 ck.getcookiestxt.com
                            0.0.0.0 eu1.clevertap-prod.com
                            0.0.0.0 wizhumpgyros.com
                            0.0.0.0 coccyxwickimp.com

                            etc

                            Many thanks

                            1 Reply Last reply Reply Quote 0
                            • stephenw10S
                              stephenw10 Netgate Administrator
                              last edited by

                              Just add a new feed and enter the URL.

                              G 1 Reply Last reply Reply Quote 0
                              • G
                                guile @stephenw10
                                last edited by guile

                                It's possible to create a blocklist only to 1 host?

                                Lets say: I want to block youtube to host 192.168.0.10.

                                What i've tried:

                                1. Add custom "DNSBL Group"
                                2. Add youtube.com in DNSBL Custom_List option
                                3. Save and Reload
                                4. Add LAN Firewall Rule to block the custom list in destination option. In source option add host IP (192.168.0.10).

                                But it doesn't work.

                                GertjanG 1 Reply Last reply Reply Quote 0
                                • stephenw10S
                                  stephenw10 Netgate Administrator
                                  last edited by

                                  Right you can't use DNS based lists in firewall rules. Potentially you could create a custom view in Unbound for just that host to prevent it resolving youtube. That's not in pfBlocker though, you should open a new thread for that if you choose to try it.

                                  1 Reply Last reply Reply Quote 0
                                  • GertjanG
                                    Gertjan @guile
                                    last edited by Gertjan

                                    @guile said in block custom domains in pfblocker:

                                    Add LAN Firewall Rule to block the custom list in destination option.

                                    A firewall rule is build with source and destination IP addresses or networks, source and destinations port.
                                    The thing is, youtube.com doesn't have 'one' IP, but several, or worse , a lot of IP addresses.
                                    Even if you were able to get them all, that list would be valid for a small amount of time - a couple of minutes.

                                    Let's test :

                                    [25.03-BETA][root@pfSense.bhf.tld]/root: host www.youtube.com
                                    www.youtube.com is an alias for youtube-ui.l.google.com.
                                    youtube-ui.l.google.com has address 172.217.18.206
                                    youtube-ui.l.google.com has address 142.250.74.238
                                    youtube-ui.l.google.com has address 142.250.75.238
                                    youtube-ui.l.google.com has address 216.58.214.174
                                    youtube-ui.l.google.com has address 172.217.20.174
                                    youtube-ui.l.google.com has address 172.217.20.206
                                    youtube-ui.l.google.com has address 216.58.215.46
                                    youtube-ui.l.google.com has address 216.58.213.78
                                    youtube-ui.l.google.com has address 142.250.179.78
                                    youtube-ui.l.google.com has address 142.250.179.110
                                    youtube-ui.l.google.com has address 142.250.178.142
                                    youtube-ui.l.google.com has address 142.250.201.174
                                    youtube-ui.l.google.com has IPv6 address 2a00:1450:4007:80c::200e
                                    youtube-ui.l.google.com has IPv6 address 2a00:1450:4007:810::200e
                                    youtube-ui.l.google.com has IPv6 address 2a00:1450:4007:80d::200e
                                    youtube-ui.l.google.com has IPv6 address 2a00:1450:4007:80e::200e
                                    

                                    So, throw "www.youtube.com" in a Alias :

                                    d6c91923-3410-4f39-9375-91bda63d54ba-image.png

                                    and now, go check this Alias :

                                    7092202b-c45a-465c-94bc-138a86d89abb-image.png

                                    and by magic, the Alias get filled with the actual IPs. Even better : the alias will get refreshed this IP list every 300 seconds or 5 minutes.

                                    This works pretty well, and probably enough so the owner of "192.168.0.10" stops trying to visit "www.youtube.com".

                                    Now, all you have to do is : create a block firewall rule on your LAN, with the source IP set to the IP of the victim : 192.168.0.10 - and a destination set the name of the alias : "youtube". Ports and other are not important = 'any'. The protocol should be set to TCP.
                                    save the rule, and have a casual visit to the owner of 192.168.0.10 and ask if "all is well ?" ;) If you don't, he'll be visiting you shortly after.

                                    Be aware : if this owner knows how to look things up, he'll find out that changing his IP to "192.168.0.11" will by pass your firewall rule ...
                                    ( and randomize its MAC, etc etc - and eventually just not using your (LAN) network anymore )

                                    No "help me" PM's please. Use the forum, the community will thank you.
                                    Edit : and where are the logs ??

                                    G 1 Reply Last reply Reply Quote 0
                                    • G
                                      guile @Gertjan
                                      last edited by

                                      @Gertjan

                                      I tried what u said and sometimes works, sometimes dont.

                                      I think the alias table refresh the IPs, and dont keep the "old" IPs.

                                      GertjanG 1 Reply Last reply Reply Quote 0
                                      • stephenw10S
                                        stephenw10 Netgate Administrator
                                        last edited by

                                        Yes, the number of IPs used by Youtube is potentially huge and varies rapidly.

                                        You can try to block by ASN but that will almost certainly catch a lot of Google's other services.

                                        G 1 Reply Last reply Reply Quote 0
                                        • G
                                          guile @stephenw10
                                          last edited by

                                          @stephenw10

                                          yea, i tried ASN but it blocks not ONLY youtube but google search, gmail, maps.. etc

                                          Ill try unbound view like u said.. never tried this before.

                                          1 Reply Last reply Reply Quote 0
                                          • GertjanG
                                            Gertjan @guile
                                            last edited by Gertjan

                                            @guile said in block custom domains in pfblocker:

                                            and sometimes works, sometimes dont.

                                            That's what the second Yellow "Warning" is all about : Hostnames in Aliases.

                                            The TTL of all Google, Microsoft, Apple, Yahoo, Facebook, etc etc is very low. And they used thousands of IP addresses, that they 'activate' and 'de activate'. So DNS re re resoltuion will happen all the time, new IPs pop up, and before the Alias thus firewall gets relaoded, a LAN client device can alreayd us an IP that wasn't listed.
                                            And ones the firewall state says ok, even if the Ip gets blocked a second later, the active state will allow traffic up until the state expires.
                                            Their (Google, and so on) hire system admins with one mission in mind : that their potential clients, and that will be the entire planet, can always reach them, whatever it takes. For the simple reason that billions ($, €, #) are at stake here. So they hired the best.

                                            As said above : you could, with pfBlockerng, go the ASN way. An ASN is an ID that contains all IPs used by the owner of that ISD (ASN).L Google has ASN 15169.
                                            Using that ASN ID, all Google (Meta) related IPs will be blocked, that will includes maps, mails, the search engine, all the addware sites, etc etc etc etc. A sledge hammer approach.
                                            It works, because Google (Youtube) won't use ASN 8075 (Microsoft owned) IPs.

                                            edit : ok, you've tried that. Works great, right 😊 and I get it, it works to well.

                                            Another solution, if you have full cooperation with the 192.168.0.10 owner, is using a proxy. The rpoxy will intercept all https requests, and filter all the web requests. If it find a "youtube.com", you could drop that request.
                                            Setting up a a proxy is a very advanced filter is complex, and imho, a real pain-in-the-admin's-but, as things constantly breaks, changes, and you have to understand how Internet actually works so you can bend the rules (a bit).

                                            No "help me" PM's please. Use the forum, the community will thank you.
                                            Edit : and where are the logs ??

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