OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • Advices to configure Unbound and Bind plugin for ad-block
« previous next »
  • Print
Pages: [1] 2 3

Author Topic: Advices to configure Unbound and Bind plugin for ad-block  (Read 27175 times)

mayo

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 4
    • View Profile
Advices to configure Unbound and Bind plugin for ad-block
« on: November 08, 2018, 01:34:41 pm »
I everybody,
I would like to configure my opnsense as internal dns server for home network.
I don't want to make mistakes, so may I ask how is the best way to configure Unbound and Bind to act (also) as an ad-block? I'm not sure how to route all traffic on lan to ask only opnsense for DNS...
Any advice is well accepted!
Logged

tofaz

  • Jr. Member
  • **
  • Posts: 58
  • Karma: 4
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #1 on: November 10, 2018, 12:58:57 am »
Hi,

in my scenario I have configured OPNsense to use Unbound and to forward my requests to external servers (you can configure it as you wish). This is beneficial first as you can cache clients requests and save up a little bit of bandwidth and dropping down responses time (unnoticeable). But you have to enable Unbound to accomplish this;

My technique is to provide a list of ads sites URLs to Unbound and configure it to refuse DNS resolutions for all of them. So far it seemed to work very well and it catches most of ads around webpages.

You can download the config file with the list that I have collected on internet here: https://tofanos.com/gabri/media/ad-blacklist.conf.

Here the steps to enable the configuration:

1) Enable SSH access to the firewall by checking System -> Settings -> Administration -> Enable Secure Shell
2) Secure copy the file in /var/unbound
3) Add “include: /var/unbound/ad-blacklist.conf” into Services -> Unbound DNS -> General -> Custom options
4) Save and apply changes
3) Disable SSH access by un-checking System -> Settings -> Administration -> Enable Secure Shell

Your clients has to use your firewall LAN address now in order to use this feature.

You can test the new config by trying to resolve from a client in your network one of the URLs listed in the file. Let’s use “adservices.google.com”:

- On a laptop open the terminal and execute nslookup adservices.google.com
You should receive the following response: server can’t find adservices.google.com: REFUSED

Now you can notice many “empty slots” in websites that you are viewing since all the ads are being blocked.

Hope this help you out!
« Last Edit: November 10, 2018, 02:27:15 am by 2fun0 »
Logged

mayo

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 4
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #2 on: November 12, 2018, 05:29:36 pm »
Thank you!
no need of Bind?
Logged

mimugmail

  • Hero Member
  • *****
  • Posts: 6767
  • Karma: 494
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #3 on: November 12, 2018, 07:56:17 pm »
Or with Bind:
https://www.routerperformance.net/opnsense/dnsbl-via-bind-plugin/
Logged
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

mayo

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 4
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #4 on: November 13, 2018, 08:45:54 am »
Thank you mimugmail, I followed your how-to, but I have a question: I made a firewall rule for all the clients for port 53 before this configuration (similar to the one on the link for port 535350) for DNS request. Do I have to disable it?
Logged

mimugmail

  • Hero Member
  • *****
  • Posts: 6767
  • Karma: 494
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #5 on: November 13, 2018, 10:20:17 am »
Do you use Unbound as primary resolver or just NAT to localhost/53530?
Logged
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

mayo

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 4
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #6 on: November 13, 2018, 02:18:49 pm »
Unbound as primary resolver (default config).
Logged

mimugmail

  • Hero Member
  • *****
  • Posts: 6767
  • Karma: 494
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #7 on: November 13, 2018, 02:22:48 pm »
Then you don't need a firewall rule.
Just add an ACL in BIND for 127.0.0.0/8 and put it in Recursion.
Then in Unbound do the forward via Advanced option like in the howto.
Logged
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

mayo

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 4
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #8 on: November 13, 2018, 02:55:44 pm »
thank you so much!
Do I have to delete rule for DNS on port 53 only or also for 53530 like described in the link (I have now two rules)?
For the ACL right now I filled in with my lan address, I will delete it and put 127.0.0.0/8 .
Sorry but I'm quite new in firewalling  :)
Logged

mimugmail

  • Hero Member
  • *****
  • Posts: 6767
  • Karma: 494
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #9 on: November 13, 2018, 06:27:26 pm »
You can remove Firewall rules as DNS is always allowed when using Unbound
Logged
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

mayo

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 4
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #10 on: November 24, 2018, 04:39:17 pm »
Quote from: mimugmail on November 13, 2018, 02:22:48 pm
Then you don't need a firewall rule.
Just add an ACL in BIND for 127.0.0.0/8 and put it in Recursion.
Then in Unbound do the forward via Advanced option like in the howto.

Tried to put 127.0.0/8 in ACL but bind plugin doesn't start.
Logged

mimugmail

  • Hero Member
  • *****
  • Posts: 6767
  • Karma: 494
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #11 on: November 24, 2018, 04:53:13 pm »
Is the listen port already in use?
What about logs?
Logged
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

mayo

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 4
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #12 on: November 24, 2018, 05:00:14 pm »
For listen I have the defaults: IP 127.0.0.1 on port 53530
no logs for Bind: File /var/log/named/named.log doesn't exist.
Logged

mimugmail

  • Hero Member
  • *****
  • Posts: 6767
  • Karma: 494
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #13 on: November 24, 2018, 05:13:39 pm »
Can you reinstall the plugin? Also please check system.log
Logged
WWW: www.routerperformance.net
Support plans: https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German): https://opnsense.max-it.de/

mayo

  • Jr. Member
  • **
  • Posts: 72
  • Karma: 4
    • View Profile
Re: Advices to configure Unbound and Bind plugin for ad-block
« Reply #14 on: November 24, 2018, 05:21:14 pm »
I've solved adding my lan /24 in the ACL. Also in ACL I have 127.0.0.0/8. Is it right?
(thank you for following me in the configuration  ;))
UPDATE: Bind started but there aren’t  query logs for service
UPDATE 2: Firewall Rule created, Bind has start to log queries.
« Last Edit: November 24, 2018, 05:43:12 pm by mayo »
Logged

  • Print
Pages: [1] 2 3
« previous next »
  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • Advices to configure Unbound and Bind plugin for ad-block
 

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