Simple-adblock: fast, lean and fully uci/luci configurable AdBlocking

Have you tried increasing the simple-adblock boot_delay option?

I've tried to increase boot_delay to 5 minutes, but the problem is still here.

simple-adblock logs on router boot
Thu Sep 15 20:41:11 2022 user.notice simple-adblock [4076]: Starting simple-adblock 1.9.0-1...
Thu Sep 15 20:41:12 2022 user.notice simple-adblock [4076]: [DL] Config  Update:  cdn.jsdelivr.net [✓]
Thu Sep 15 20:41:13 2022 user.notice simple-adblock [4076]: [DL] Blocked Domains: cdn.jsdelivr.net [✓]
Thu Sep 15 20:41:13 2022 user.notice simple-adblock [4076]: [DL] Blocked Hosts:   cdn.jsdelivr.net [✓]
Thu Sep 15 20:41:14 2022 user.notice simple-adblock [4076]: [DL] Blocked Domains: s3.amazonaws.com [✓]
Thu Sep 15 20:41:15 2022 user.notice simple-adblock [4076]: [DL] Blocked Hosts:   winhelp2002.mvps.org [✓]
Thu Sep 15 20:41:19 2022 user.notice simple-adblock [4076]: [DL] Blocked Hosts:   someonewhocares.org [✓]
Thu Sep 15 20:41:19 2022 user.notice simple-adblock [4076]: Sorting combined list [✓]
Thu Sep 15 20:41:32 2022 user.notice simple-adblock [4076]: Optimizing combined list [✓]
Thu Sep 15 20:41:32 2022 user.notice simple-adblock [4076]: Allowing domains [✓]
Thu Sep 15 20:41:32 2022 user.notice simple-adblock [4076]: Formatting merged file [✓]
Thu Sep 15 20:41:32 2022 user.notice simple-adblock [4076]: Creating DNSMASQ servers file [✓]
Thu Sep 15 20:41:33 2022 user.notice simple-adblock [4076]: Removing temporary files [✓]
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: read /etc/hosts - 4 addresses
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: read /tmp/hosts/dhcp.cfg01411c - 2 addresses
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: read /tmp/hosts/odhcpd - 1 addresses
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq-dhcp[1]: read /etc/ethers - 0 addresses
Thu Sep 15 20:41:33 2022 daemon.err dnsmasq[1]: cannot read /var/run/simple-adblock/dnsmasq.servers: No such file or directory
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using nameserver 208.67.222.222#53
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using nameserver 4.4.4.4#53
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using nameserver 8.8.8.8#53
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using nameserver 82.209.200.16#53
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using nameserver 82.209.200.17#53
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using only locally-known addresses for test
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using only locally-known addresses for onion
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using only locally-known addresses for localhost
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using only locally-known addresses for local
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using only locally-known addresses for invalid
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using only locally-known addresses for bind
Thu Sep 15 20:41:33 2022 daemon.info dnsmasq[1]: using only locally-known addresses for lan
Thu Sep 15 20:41:33 2022 user.notice simple-adblock [4076]: Reloading DNSMASQ [✓]
Thu Sep 15 20:41:33 2022 user.notice simple-adblock [4076]: service is blocking 19114 domains (with dnsmasq.servers) [✓]
Thu Sep 15 20:41:34 2022 daemon.info procd: - init complete -
And there logs after I manually restarted dnsmasq
Thu Sep 15 20:44:53 2022 daemon.info dnsmasq[1]: exiting on receipt of SIGTERM
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: started, version 2.86 cachesize 150
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: DNS service limited to local subnets
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: compile time options: IPv6 GNU-getopt no-DBus UBus no-i18n no-IDN DHCP no-DHCPv6 no-Lua TFTP no-conntrack no-ipset no-auth no-cryptohash no-DNSSEC no-ID loop-detect inotify dumpfile
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: UBus support enabled: connected to system bus
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq-dhcp[1]: DHCP, IP range 192.168.1.100 -- 192.168.1.249, lease time 12h
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for test
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for onion
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for localhost
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for local
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for invalid
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for bind
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for lan
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: reading /tmp/resolv.conf.d/resolv.conf.auto
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using nameserver 208.67.222.222#53
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using nameserver 4.4.4.4#53
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using nameserver 8.8.8.8#53
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using nameserver 82.209.200.16#53
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using nameserver 82.209.200.17#53
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for test
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for onion
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for localhost
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for local
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for invalid
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for bind
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: using only locally-known addresses for lan
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: read /etc/hosts - 4 addresses
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: read /tmp/hosts/dhcp.cfg01411c - 2 addresses
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq[1]: read /tmp/hosts/odhcpd - 1 addresses
Thu Sep 15 20:44:56 2022 daemon.info dnsmasq-dhcp[1]: read /etc/ethers - 0 addresses
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 208.67.222.222#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 4.4.4.4#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 8.8.8.8#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 82.209.200.16#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 82.209.200.17#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zytpirwai.net
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zyrtec.4.p2l.info
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zyrtec.3.p2l.info
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zyrtec.1.p2l.info
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zymerget.win
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zymerget.stream
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zymerget.party
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zymerget.faith
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using 19113 more local addresses
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 208.67.222.222#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 4.4.4.4#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 8.8.8.8#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 82.209.200.16#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using nameserver 82.209.200.17#53
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zytpirwai.net
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zyrtec.4.p2l.info
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zyrtec.3.p2l.info
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zyrtec.1.p2l.info
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zymerget.win
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zymerget.stream
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zymerget.party
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using only locally-known addresses for zymerget.faith
Thu Sep 15 20:44:57 2022 daemon.info dnsmasq[1]: using 19113 more local addresses

So there are no entries from dnsmasq immediately below this? Do you feel comfortable editing 2 lines of the init file on the router to test something?

Yeah, no more logs after this and I'm ready to test any config edits

If you could try changing two lines in the /etc/init.d/simple-adblock from:
param=dnsmasq_hup
to
param=dnsmasq_restart

I believe it would solve the issue.

In the latest code of simple-adblock, that's lines 411 and 452. There are only two entries like that in the whole file anyways.

Hello,

Can you please answer this question posted in another thread for simple adblock?

For https://d3ward.github.io/toolz/adblock.html I get 10%
and for https://adblock-tester.com/ I get 28 points out of 100

Thank you,

I'm not sure what the second link is testing, there are certainly add-ons for browsers which can parse the whole page being loaded and block specific elements of that page, that's not how router-based ad-blocking works. Either adblock or simple-adblock block the domains, they have no access to the actual web pages you load..

So the first link in that post (https://d3ward.github.io/toolz/adblock.html, which tests which domains are blocked) -- you can have as little as 0% or as much as 100%, depending on what you need/want. Whatever domains from that list which are not blocked thru the downloadable sources you can block in the simple-adblock settings yourself (and achieve 100% on that site if that's so important to you).

2 Likes

It worked for me, after boot delay I can see the log daemon.info dnsmasq[1]: using 19111 more local addresses and ad is blocked

Thanks for testing, I'll fix it in the source and send PR.

1 Like

If you could test 1.9.1-1 from my repo before I send the PR, I'd appreciate it.

I've followed the instruction, after that I've upgraded simple-adblock packages to 1.9.1-1

And it doesn't work for me and shows a lot of errors like this:

Sun Sep 18 08:13:09 2022 user.notice simple-adblock [4104]: ERROR: failed to create /var/run/simple-adblock/dnsmasq.servers file!
Sun Sep 18 08:13:09 2022 daemon.notice procd: /etc/rc.d/S94simple-adblock: /etc/rc.common: eval: line 555: can't create /var/run/simple-adblock/simple-adblock.json: nonexistent directory
Sun Sep 18 08:13:09 2022 daemon.notice procd: /etc/rc.d/S94simple-adblock: /etc/rc.common: eval: line 555: can't create /var/run/simple-adblock/simple-adblock.json: nonexistent directory

Oh, thanks for catching this, if you redownload/reinstall the package, it's been fixed.

1 Like

It's working now without problems

2 Likes

Thanks for your feedback and a lot of testing, I'll try to send PR for an updated version to master branch some time this week and I'll probably cherry-pick it for 22.03, but not older releases.

3 Likes

Howdy! Absolutely adore the simple-adblock package. One note and maybe I'm not seeing a setting. Rebooting causes the force_dns firewall rules to disappear. If I reapply the config they reappear but do they have any persistence? I'm still new to the openwrt platform but I am trying to learn the location of configs and settings.

How do you check if the rules are still there?

They should be reapplied on each service start (and boot as well).

I am going to status > firewall and I usually see the rules in Rule container chain "dstnat_lan" and Rule container chain "forward_lan". Is there a .nft file that contains the rules that are applied on boot?

Let me conduct some tests.

No, it's the PROCD firewall object which is added on start. Can you test something please. If you don't see the firewall redirects in the list next time, instead of restarting simple-adblock, could you please do fw4 reload?

I suspect that the issue might be that simple-adblock does create the PROCD object with firewall redirects, but fails to reload firewall with the new setting.

Rebooted, waited a few minutes for the blocked host list to download and checked the status > firewall section and nothing.

fw4 -v reload also didn't load your rules.

Heres my config as it stands:

        option config_update_url 'https://cdn.jsdelivr.net/gh/openwrt/packages/net/simple-adblock/files/simple-adblock.conf.update'
        option dns_instance '0'
        option verbosity '2'
        option force_dns '1'
        list force_dns_port '53'
        list force_dns_port '853'
        option led 'none'
        option boot_delay '120'
        option download_timeout '10'
        option curl_retry '3'
        option parallel_downloads '1'
        option debug '0'
        option compressed_cache '0'
        option enabled '1'
        list blocked_hosts_url 'https://cdn.jsdelivr.net/gh/StevenBlack/hosts@master/alternates/fakenews/hosts'
        option dns 'dnsmasq.addnhosts'
        option ipv6_enabled '1'
        option config_update_enabled '1'

simply saving and applying without making any changes adds the rules.

I appreciate you trying to investigate this. Have you tried to play with boot_delay option? Does that help if you set it to 15/30/60 seconds? I may reach out directly if I have any other ideas why procd firewall object is not being created.