Ad blocking on WRT1900ACv2

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.)
Author Message
andrewvideo
DD-WRT Novice


Joined: 21 Jun 2019
Posts: 5

PostPosted: Fri Jun 21, 2019 22:23    Post subject: Ad blocking on WRT1900ACv2 Reply with quote
I am looking for help to block ads on my WRT1900ACv2

my WRT1900ACv2 not blocking any ads.

I tried using this guide https://wiki.dd-wrt.com/wiki/index.php/Ad_blocking

Firmware: DD-WRT v3.0-r37305 std (10/10/1Cool
WRT1900ACv2

Also tried a full reset.

Can some tell me what I am doing worng or this guide work with my router.

Thank you for your help
Sponsor
Eyerex
DD-WRT User


Joined: 11 Feb 2016
Posts: 151
Location: South London

PostPosted: Sat Jun 22, 2019 9:26    Post subject: Reply with quote
I tried setting up when i first got my WRT1900 but in the end i bought a Raspberry Pi to run PiHole
_________________
| Netgear Nighthawk X4S R7800 | Linksys WRT1900ACS V1 | Huawei Echolife HG612 3B |
andrewvideo
DD-WRT Novice


Joined: 21 Jun 2019
Posts: 5

PostPosted: Sat Jun 22, 2019 11:22    Post subject: Reply with quote
I don't realy want to use the pi hole. Plus the router is good engoh to the job. I know the pi hole is realy good. just means I need to go out buy one and plus more cables. I like my set up to be clean.

Aslo I not sure 3m ethernet cable (POE) - cat6 can take the power of the router and the pi same time. I would plug the pi in the router USB port.
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8025

PostPosted: Sat Jun 22, 2019 18:34    Post subject: Reply with quote
For the time being, I'm going to avoid dealing w/ the second example in that wiki, since it seems overly complex. And you weren't specific about which script you were interested in anyway.

The first script has several flaws.

1. It assumes the WAN is up by the time the script is executed in the startup script, which is normally NOT the case. The startup script is executed long before the WAN is established, and therefore anything that depends on the WAN being available will fail, like using wget to retrieve the URL.

2. It assumes dnsmasq is running. Sometimes it is, sometimes not, by the time the startup script is executed. And if it's not, and the router's execution of dnsmasq gets started *after* you make your changes, those changes will be overwritten!

3. The router should check that wget is available. I know it usually is, but you'd be surprised how many times something you assume to be available, ends up NOT being available. For example, nothing stops the developers from deciding one day to switch to curl rather than the more outdated wget. The developers implement the utilities *they* need, for *their* own reasons, NOT for the sake of script developers.

4. These days, you can't assume that http is available. A lot of sites are switching to https. And while I did verify that at least for the time being, the URL as specific w/ http works, it's still not good practice to make that assumption.

In short, the script, as written, is neither robust nor reliable. And therefore it should be rewritten to avoid confusion by users who expect it to work.

For a quick fix, you could add the following right after the shebang (#!/bin/sh) to actually force the script to wait for the WAN to be up and available.

Code:
while ! ping -qc1 -w3 8.8.8.8 > /dev/null 2>&1; do sleep 10; done


Whether that's the only problem, I don't know.

Frankly, this would be better suited as a WAN Up script, not a startup script, but for the time being, that should suffice. What I'll probably do, when I get the time, is rewrite it and post a link to it here.

_________________
DD-WRT: DNS Leak Detection w/ VPNs (updated 6/5/19)
NEW SCRIPT!: ddwrt-mount-usb-drives.sh
NEW SCRIPT!: ddwrt-blacklist-domains.sh
NEW SCRIPT!: ddwrt-ovpn-remote-access.sh
NEW SCRIPT!: ddwrt-pptp-policy-based-routing.sh
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8025

PostPosted: Sun Jun 23, 2019 7:23    Post subject: Reply with quote
As promised, I reworked several scripts and came up w/ my own. Perhaps you'll have more success with it.

ddwrt-blacklist-domains.sh

_________________
DD-WRT: DNS Leak Detection w/ VPNs (updated 6/5/19)
NEW SCRIPT!: ddwrt-mount-usb-drives.sh
NEW SCRIPT!: ddwrt-blacklist-domains.sh
NEW SCRIPT!: ddwrt-ovpn-remote-access.sh
NEW SCRIPT!: ddwrt-pptp-policy-based-routing.sh
andrewvideo
DD-WRT Novice


Joined: 21 Jun 2019
Posts: 5

PostPosted: Sun Jun 23, 2019 11:11    Post subject: Reply with quote
Do my router have JFFS Support? I cant seem to get it to work.

Tried this no luck

The steps to enable JFFS through the router web page are very specific. To avoid having to reset and reprogram your router, it's smart to make a backup here of your settings. If you follow these steps exactly, it should not lock up.

On the router web page click on Administration.
Scroll down until you see JFFS2 Support section.
Click Enable JFFS.
Click Save.
Wait couple seconds, then click Apply.
Wait again. Go back to the Enable JFFS section, and enable Clean JFFS.
Do not click "Save". Click Apply instead.

The router formats the available space.

Wait till you get the web-GUI back, then disable "Clean JFFS" again.
Click "Save".
Reboot the router,

Also tried

Code:
nvram set jffs_mounted=1
nvram set enable_jffs2=1
nvram set sys_enable_jffs2=1
nvram set clean_jffs2=1
nvram set sys_clean_jffs2=1
nvram commit
reboot
andrewvideo
DD-WRT Novice


Joined: 21 Jun 2019
Posts: 5

PostPosted: Sun Jun 23, 2019 14:44    Post subject: Reply with quote
I downgraged the firmwire and got eveything working

Thank you for your help and time.
andrewvideo
DD-WRT Novice


Joined: 21 Jun 2019
Posts: 5

PostPosted: Sun Jun 23, 2019 14:52    Post subject: Reply with quote
I trun off the router and now the ads are not been blocked. Is something I Missing? Cheers
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 8025

PostPosted: Sun Jun 23, 2019 15:26    Post subject: Reply with quote
Make sure you're using the absolute latest release. I just updated the script. One of the early releases wasn't waiting for the WAN and DNSMasq to come up, so it could fail. I've since corrected that problem and updated the script.

I also added some code to allow serialization, in case a second instance got started at the same time as the current instance (not likely, but remotely possible given the script can be added to the scheduler (cron)). Also, I found some malformed domain names in the list (weird characters, domains w/ port numbers, etc.) and added code to remove them.

If the script is in /jffs/etc/config, it should autostart on every boot. Once the script completes, and assuming the syslog is enabled, you should be able to find the total blacklisted domains w/ the following shell command:

Code:
cat /var/log/messages | grep total


Also, look for any errors ...

Code:
cat /var/log/messages | grep error


I noticed that sometimes certain urls could not be retrieved reliably. Not clear why that's the case.

Btw, I noticed on one of my more recent builds that BS (Brainslayer) has added adblocking in the GUI, via Privoxy. Not sure if that is limited to only certain routers. Don't know how well it works either, or whether updates to its blocking list would require updating Privoxy as a whole. But just something to be aware of.

_________________
DD-WRT: DNS Leak Detection w/ VPNs (updated 6/5/19)
NEW SCRIPT!: ddwrt-mount-usb-drives.sh
NEW SCRIPT!: ddwrt-blacklist-domains.sh
NEW SCRIPT!: ddwrt-ovpn-remote-access.sh
NEW SCRIPT!: ddwrt-pptp-policy-based-routing.sh
Zyxx
DD-WRT Novice


Joined: 28 Dec 2018
Posts: 32

PostPosted: Sun Jun 23, 2019 17:31    Post subject: Reply with quote
Here the excerpt responsible for "ad blocking" on my Wifi router:
Code:

sleep 20
# get hosts file with unix EOL
wget -qO- http://www.mvps.org/winhelp2002/hosts.txt|grep "^0.0.0.0" >> /tmp/hosts
# re-read hosts file
killall -HUP dnsmasq

Copied years ago from this forum, somewhere... Kudos to the author Smile

It just works, ads are nearly gone. Finaly able to surf with tablet and mobile.
Since my router restarts at 5'o clock in the morning, the list is refreshed once a day.

Of course the solution is not perfect, but lightweight.

1) Get the file as terminalwindow
2) grep every line beginning with 0.0.0.0 into tmp/hosts
3) restart dnsmasq (issued cause "hangup")
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.) All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum