OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 18.1 Legacy Series »
  • How to implement something similar to pfBlockerNg?
« previous next »
  • Print
Pages: [1] 2

Author Topic: How to implement something similar to pfBlockerNg?  (Read 13969 times)

hilfubsi

  • Newbie
  • *
  • Posts: 43
  • Karma: 2
    • View Profile
How to implement something similar to pfBlockerNg?
« on: February 08, 2018, 05:02:20 pm »
I would like to block ads network wide, similar to what pfBlockerNg/PiHole does. I would also like the firewall to block the ad domains, not only for the DNS to resolve them to a dummy IP. This is for the Android YouTube app for example that does its own DNS and for which DNS ad blocking isn't effective.

How would I go about it in OPNsense? There doesn't seem to be a pfBlockerNg plugin available.
Logged

elektroinside

  • Hero Member
  • *****
  • Posts: 574
  • Karma: 51
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #1 on: February 08, 2018, 05:41:11 pm »
I also would love to see Pi-hole (or something similar to handle lists and maintain a customizable whitelist / ability to whitelist a blocked domain once it's accessed with an easy GUI) integrated somehow into OPNsense.
But.. no Pi-hole on FreeBSD based systems. So I just deployed Pi-hole on another machine... and waiting for the future to bring something new :)

One thing's for sure, as long as there are workarounds, I will not ditch OPNsense.
« Last Edit: February 08, 2018, 05:54:07 pm by elektroinside »
Logged
OPNsense v18 | HW: Gigabyte Z370N-WIFI, i3-8100, 8GB RAM, 60GB SSD, | Controllers: 82575GB-quad, 82574, I221, I219-V | PPPoE: RDS Romania | Down: 980Mbit/s | Up: 500Mbit/s

Team Rebellion Member

fabian

  • Hero Member
  • *****
  • Posts: 2768
  • Karma: 199
  • OPNsense Contributor (Language, VPN, Proxy, etc.)
    • View Profile
    • Personal Homepage
Re: How to implement something similar to pfBlockerNg?
« Reply #2 on: February 08, 2018, 05:43:48 pm »
you can do that in the proxy for the best results (docs are available). IPS would work as well.
Logged

elektroinside

  • Hero Member
  • *****
  • Posts: 574
  • Karma: 51
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #3 on: February 08, 2018, 05:57:55 pm »
Except for the proxy, don't like it :)
I am using IDS/IPS, but also Pi-hole. Not an issue for me :)
Logged
OPNsense v18 | HW: Gigabyte Z370N-WIFI, i3-8100, 8GB RAM, 60GB SSD, | Controllers: 82575GB-quad, 82574, I221, I219-V | PPPoE: RDS Romania | Down: 980Mbit/s | Up: 500Mbit/s

Team Rebellion Member

hilfubsi

  • Newbie
  • *
  • Posts: 43
  • Karma: 2
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #4 on: February 08, 2018, 06:27:08 pm »
Quote from: fabian on February 08, 2018, 05:43:48 pm
you can do that in the proxy for the best results (docs are available). IPS would work as well.

It doesn't seem to understand adblock formatted lists though, does it? The UToulouse list is more intended to censor internet access than to block ads.
Logged

fabian

  • Hero Member
  • *****
  • Posts: 2768
  • Karma: 199
  • OPNsense Contributor (Language, VPN, Proxy, etc.)
    • View Profile
    • Personal Homepage
Re: How to implement something similar to pfBlockerNg?
« Reply #5 on: February 08, 2018, 07:14:03 pm »
Quote from: hilfubsi on February 08, 2018, 06:27:08 pm
It doesn't seem to understand adblock formatted lists though, does it? The UToulouse list is more intended to censor internet access than to block ads.

There are other lists like https://pgl.yoyo.org/as/ for ad blocking using a hosts file or a proxy. Ad blockers do have a different syntax which allows basically two things:

* cosmetic filtering (hide stuff from the page)
* network filters (URL and content type filters)

Cosmetic filters will probably not work well on a firewall appliance because of false positives and that may break the pages entirely while network filters are possible but the syntax is not compatible (the proxy cannot read the format of the easylist).
Logged

hilfubsi

  • Newbie
  • *
  • Posts: 43
  • Karma: 2
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #6 on: February 10, 2018, 08:03:04 pm »
I can't get this to work :(

I added the yoyo list to ACL and enabled it, but if I curl http://secure.quantserve.com/quant.js, it is not blocked. It's going through the proxy because I see the extra headers in the response.
Logged

xmichielx

  • Newbie
  • *
  • Posts: 44
  • Karma: 0
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #7 on: March 08, 2018, 10:35:35 am »
Quote from: fabian on February 08, 2018, 05:43:48 pm
you can do that in the proxy for the best results (docs are available). IPS would work as well.

Is there an option to do this via DNS?
Proxy only blocks HTTP and HTTPS takes a lot of work to be fixed on all devices and cause extra load on an APU2.
DNS is very to set up and very lightweight and works out of the box for all devices.
There is a reason why the pihole is such a succes not a squid proxy on a raspberry pi ;)
It would be really nice if the WebGUI offers an option to add a list like yoyo to block ads.
Logged

elektroinside

  • Hero Member
  • *****
  • Posts: 574
  • Karma: 51
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #8 on: March 08, 2018, 10:48:11 am »
It would be awesome if hosts files could be imported (with additional features, like an update scheduler, whitelist + blacklist, and an alerts UI - otherwise it would be difficult to maintain) from the GUI. It would make a phenomenal addition IMO.
Logged
OPNsense v18 | HW: Gigabyte Z370N-WIFI, i3-8100, 8GB RAM, 60GB SSD, | Controllers: 82575GB-quad, 82574, I221, I219-V | PPPoE: RDS Romania | Down: 980Mbit/s | Up: 500Mbit/s

Team Rebellion Member

mimugmail

  • Hero Member
  • *****
  • Posts: 6332
  • Karma: 435
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #9 on: March 08, 2018, 11:02:38 am »
Quote from: xmichielx on March 08, 2018, 10:35:35 am
Quote from: fabian on February 08, 2018, 05:43:48 pm
you can do that in the proxy for the best results (docs are available). IPS would work as well.

Is there an option to do this via DNS?
Proxy only blocks HTTP and HTTPS takes a lot of work to be fixed on all devices and cause extra load on an APU2.
DNS is very to set up and very lightweight and works out of the box for all devices.
There is a reason why the pihole is such a succes not a squid proxy on a raspberry pi ;)
It would be really nice if the WebGUI offers an option to add a list like yoyo to block ads.

This?
https://devinstechblog.com/block-ads-with-dns-in-opnsense/
Logged
Twitter: mimu_muc
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

Evil_Sense

  • Full Member
  • ***
  • Posts: 112
  • Karma: 15
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #10 on: March 08, 2018, 11:05:40 am »
Quote from: mimugmail on March 08, 2018, 11:02:38 am
Quote from: xmichielx on March 08, 2018, 10:35:35 am
Quote from: fabian on February 08, 2018, 05:43:48 pm
you can do that in the proxy for the best results (docs are available). IPS would work as well.

Is there an option to do this via DNS?
Proxy only blocks HTTP and HTTPS takes a lot of work to be fixed on all devices and cause extra load on an APU2.
DNS is very to set up and very lightweight and works out of the box for all devices.
There is a reason why the pihole is such a succes not a squid proxy on a raspberry pi ;)
It would be really nice if the WebGUI offers an option to add a list like yoyo to block ads.

This?
https://devinstechblog.com/block-ads-with-dns-in-opnsense/
That's what I use, works flawlessly
Logged

elektroinside

  • Hero Member
  • *****
  • Posts: 574
  • Karma: 51
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #11 on: March 08, 2018, 12:07:19 pm »
Yes, it works. But this is difficult to maintain, unfortunately, even with the script.
Logged
OPNsense v18 | HW: Gigabyte Z370N-WIFI, i3-8100, 8GB RAM, 60GB SSD, | Controllers: 82575GB-quad, 82574, I221, I219-V | PPPoE: RDS Romania | Down: 980Mbit/s | Up: 500Mbit/s

Team Rebellion Member

Evil_Sense

  • Full Member
  • ***
  • Posts: 112
  • Karma: 15
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #12 on: March 08, 2018, 12:19:14 pm »
Quote from: elektroinside on March 08, 2018, 12:07:19 pm
Yes, it works. But this is difficult to maintain, unfortunately, even with the script.
I created a cron action to call the script, at least this can be controlled by webGUI, the include too.

Sure, more controll included in the webGUI would be great.
« Last Edit: March 08, 2018, 12:21:15 pm by Evil_Sense »
Logged

elektroinside

  • Hero Member
  • *****
  • Posts: 574
  • Karma: 51
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #13 on: March 08, 2018, 12:34:40 pm »
Yes, but that's not the difficult part to maintain. It's the editing of the blacklists/whitelists that is difficult to maintain.

Think about the flow. A user hits a blacklisted domain. You have to manually open/edit a few files to whitelist, which means you have to ssh to your box. Then, you have to trigger or wait for the cron job or reload manually. And you have to take care your new whitelist is there after a cron job update (and nothing fails).

Not to mention that you should redirect your users to a webserver to display a nice message if you hit a blacklisted domain. But with this, you should also consider the cosmetic aspects of stuff if a blacklisted domain is hit inside an iframe for example, iframe which is part of a whitelisted domain. And this is just one use case.
« Last Edit: March 08, 2018, 12:37:32 pm by elektroinside »
Logged
OPNsense v18 | HW: Gigabyte Z370N-WIFI, i3-8100, 8GB RAM, 60GB SSD, | Controllers: 82575GB-quad, 82574, I221, I219-V | PPPoE: RDS Romania | Down: 980Mbit/s | Up: 500Mbit/s

Team Rebellion Member

xmichielx

  • Newbie
  • *
  • Posts: 44
  • Karma: 0
    • View Profile
Re: How to implement something similar to pfBlockerNg?
« Reply #14 on: March 12, 2018, 05:26:14 pm »
The problem I have with doing things on the shell is that they might get lost after an upgrade.
I know there are a bunch of scripts but I want to make sure that the list and the cronjob are there after an upgrade of OPNsense, hence my request to allow this via unbound/dnsmasq webgui (a simple curl command to a remote location and adding it to an included .conf is the real magic).
A cronjob would also be nice to update the list every day/week etc. :)
Logged

  • Print
Pages: [1] 2
« previous next »
  • OPNsense Forum »
  • Archive »
  • 18.1 Legacy Series »
  • How to implement something similar to pfBlockerNg?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2023 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2