ad-blocking with DD-WRT revisited (simple)

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2, 3 ... , 12, 13, 14  Next
Author Message
miggalvez
DD-WRT Novice


Joined: 15 Dec 2016
Posts: 19

PostPosted: Fri Dec 23, 2016 15:25    Post subject: Reply with quote
jcdole wrote:
jcdole wrote:
ironmanlok wrote:
Sorry guys, didn't notice this thread was updated.

I changed my script a few months ago to interpret http codes and keep trying each URL up to 3 times and then skip to next URL, I just forgot to upload it here.

Also, I just replaced the jansaw list URL to point to github.


Seems working.

Thank you very much


There is an error with url :
https://raw.githubusercontent.com/lewisje/jansal/master/adblock/hosts
curl return an error 301.

Trying with wget, get this error :
Code:
Connecting to raw.githubusercontent.com (151.101.120.133:80)
Connecting to raw.githubusercontent.com (151.101.120.133:443)
wget: error getting response: Resource temporarily unavailable


One can see the list using firefox

Any help is welcome.


I think it has to do with the fact that it is a https URL. Add -k to curl parameters. Line 99 of the script:

Code:
(curl -k -o "$TEMP_FILE" --silent --write-out '%{http_code}' --connect-timeout 60 --max-time 120 "$URL" > "$HTTP_CODE") & DOWNLOAD_PID=$!


See if that works.
Sponsor
jcdole
DD-WRT Novice


Joined: 13 Jun 2015
Posts: 29
Location: South-West France

PostPosted: Mon Dec 26, 2016 11:50    Post subject: Reply with quote
Hello.

To day,
Code:
 curl -k -o
works
and
Code:
curl -o
works also

To day
Code:
wget
works also.

???????????

Any comments ?

Should I keep
Code:
 curl -k -o

_________________
Netgear R6300v2 rev30082-Linux Opensuse Leap 42.3
drdedus
DD-WRT User


Joined: 31 Dec 2013
Posts: 85
Location: Greece

PostPosted: Sun Jan 08, 2017 23:38    Post subject: Reply with quote
i have successfully block ads in my router.
is there any workaround so the router can act like a dns proxy for other devices out of our network?
I want to block ads in my android phone when I am connected to a friend's wifi (without to root) just using my ddwrt like dns proxy.
goodspeed:|
DD-WRT Novice


Joined: 05 Dec 2016
Posts: 12

PostPosted: Tue Jan 10, 2017 1:47    Post subject: Reply with quote
[quote="drdedus"]i have successfully block ads in my router.
is there any workaround so the router can act like a dns proxy for other devices out of our network?
I want to block ads in my android phone when I am connected to a friend's wifi (without to root) just using my ddwrt like dns proxy.[/quote]

turn on vpn server with full tunnel
00diabolic
DD-WRT Novice


Joined: 17 Aug 2011
Posts: 33

PostPosted: Fri Jan 27, 2017 15:50    Post subject: Adblocking using client bridge machine will this work? Reply with quote
Hi all,

I have my network setup with my main router being the DSL modem/router combo unit that does not run ddwrt. Before you suggest it, yes I have thought of just allowing this unit to be the modem only and attaching a ddwrt router to the output to do all the routing, but have not decided to buy a 3rd ddwrt router.

Currently I have 2 client bridges in different locations connected to multiple wired devices, allowing them all to stay off wireless and communicate over the bridge.

On my main DSL modem router I can specify DNS. So I figured I can use 1x of the client bridges to handle DNS and thus block ads. So I setup the dnsmasiq on client bridge using fraters original instructions. I then pointed my modem router dns at the client bridge.

The problem is it does not work. What else do i have to do? Think of this like using pi-hole. I am basically following the same procedure here, diverting the DNS to the client bridge much like you would do with the PI. The only difference is the bridge is wireless not wired. Could that be the problem? Does each computer/device have to have its DNS changed to point at the client bridge also, like the pi hole setup?
aiyapk
DD-WRT Novice


Joined: 27 Jul 2012
Posts: 4

PostPosted: Sun Apr 02, 2017 16:55    Post subject: Reply with quote
Update the script from h8red to allow exceptions.

Code:

_exception='www.kqzyfj.com\|www.googleadservices.com'
_rogue=0.0.0.0
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://winhelp2002.mvps.org/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^0.0.0.0\" /tmp/hsts | grep \"^0.0.0.0\" | grep -v localhost | grep -v \"$_exception\" | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


To make this work:

Under Service > Services > DNSMasq
Local DNS = Enabled
Add: addn-hosts=/tmp/dlhosts
Edit _exception to add your own allowed domains
Add Startup Script: (see above)
Add to Additional CronJobs (runs on the first of every month at 4am): 0 4 1 * * root /tmp/.rc_startup
ess2k
DD-WRT Novice


Joined: 27 Oct 2017
Posts: 6

PostPosted: Sat Oct 28, 2017 22:22    Post subject: Reply with quote
h8red wrote:
162884 wrote:
I don't think it's working, how can I test to be sure it is Thanks


Add startup Script:
_rogue=0.0.0.0
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://winhelp2002.mvps.org/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^0.0.0.0\" /tmp/hsts | grep \"^0.0.0.0\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


Add to Additional DNS Masquerade options:
addn-hosts=/tmp/dlhosts


Add to Additional CronJobs
0 12 * * * root /tmp/.rc_startup


is it possible to add multiple host file sources with this?

Thanks
ryencoke
DD-WRT Novice


Joined: 15 Nov 2017
Posts: 1

PostPosted: Wed Nov 15, 2017 0:40    Post subject: Reply with quote
ess2k wrote:
h8red wrote:
162884 wrote:
I don't think it's working, how can I test to be sure it is Thanks


Add startup Script:
_rogue=0.0.0.0
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://winhelp2002.mvps.org/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^0.0.0.0\" /tmp/hsts | grep \"^0.0.0.0\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


Add to Additional DNS Masquerade options:
addn-hosts=/tmp/dlhosts


Add to Additional CronJobs
0 12 * * * root /tmp/.rc_startup


is it possible to add multiple host file sources with this?

Thanks


This will add the adaway.org/hosts.txt. Note, this hosts file is from https and my version of wget only supports http, so used curl instead. YMMV

Code:

_exception='www.kqzyfj.com\|www.googleadservices.com'
_rogue=0.0.0.0
echo -e "n=1\nwhile ! curl -k -o /tmp/hsts2 --silent https://adaway.org/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\nn=1\nwhile ! wget -q -O /tmp/hsts http://winhelp2002.mvps.org/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\nawk -v r=\"$_rogue\" '{sub(/^127.0.0.1/, r)} \$0 ~ \"^\"r' /tmp/hsts2 >> /tmp/hsts\nrm /tmp/hsts2\nawk '{print \$1,\$2}' /tmp/hsts|sort -u | grep \"^$_rogue\" /tmp/hsts | grep -v localhost | grep -v \"$_exception\" | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' > /tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &
patrck744
DD-WRT Novice


Joined: 17 Sep 2015
Posts: 4

PostPosted: Wed Nov 15, 2017 22:13    Post subject: Reply with quote
ryencoke wrote:
ess2k wrote:
h8red wrote:
162884 wrote:
I don't think it's working, how can I test to be sure it is Thanks


Add startup Script:
_rogue=0.0.0.0
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://winhelp2002.mvps.org/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^0.0.0.0\" /tmp/hsts | grep \"^0.0.0.0\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


Add to Additional DNS Masquerade options:
addn-hosts=/tmp/dlhosts


Add to Additional CronJobs
0 12 * * * root /tmp/.rc_startup


is it possible to add multiple host file sources with this?

Thanks


This will add the adaway.org/hosts.txt. Note, this hosts file is from https and my version of wget only supports http, so used curl instead. YMMV

Code:

_exception='www.kqzyfj.com\|www.googleadservices.com'
_rogue=0.0.0.0
echo -e "n=1\nwhile ! curl -k -o /tmp/hsts2 --silent https://adaway.org/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\nn=1\nwhile ! wget -q -O /tmp/hsts http://winhelp2002.mvps.org/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\nawk -v r=\"$_rogue\" '{sub(/^127.0.0.1/, r)} \$0 ~ \"^\"r' /tmp/hsts2 >> /tmp/hsts\nrm /tmp/hsts2\nawk '{print \$1,\$2}' /tmp/hsts|sort -u | grep \"^$_rogue\" /tmp/hsts | grep -v localhost | grep -v \"$_exception\" | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' > /tmp/dlhosts\nrm /tmp/hsts\nkillall -HUP dnsmasq" >/tmp/wh
sh /tmp/wh &


This doesn't work anymore with the latest <Kong> and BS builds. This worked on 33555 but after that it gives me an error every time it is started.

Forgot to mention:

Router: R7800
drdedus
DD-WRT User


Joined: 31 Dec 2013
Posts: 85
Location: Greece

PostPosted: Sun Dec 03, 2017 18:50    Post subject: Reply with quote
I think too it doesn't work anymore.
Any solution?
I am trying adguard dns blocking but it doesn't cut all the advertising especially inside android apps
Yamaraj
DD-WRT User


Joined: 25 Jan 2017
Posts: 91

PostPosted: Mon Dec 04, 2017 6:46    Post subject: Reply with quote
Try this https://www.dd-wrt.com/phpBB2/viewtopic.php?t=307533

Should work on 7800 too.

_________________

Router
Netgear R8500: DD-WRT v3.0-r36070M kongac (05/31/18) / SFE: quarkysg - r34080-linux-4.4.105

Scripts
Ad-blocking on DD-WRT -- Github
mac913
DD-WRT Guru


Joined: 02 May 2008
Posts: 1241
Location: Canada

PostPosted: Fri Dec 08, 2017 7:14    Post subject: Reply with quote
I have a familiy members E3000 router on Build 33986 K3.x that needed adblocking. Initially it wasn't fully working and after troubleshooting the ads where also going through IPv6 connections and bypassing the script that is setup for only IPv4. I searching on the web I have a working Adblock script for both IPv4 and IPv6.

Startup GUI...

# Adblocker IPv4 & IPv6
#
# Download IPv4 hosts file and Remove all remarks
rm /tmp/dlhosts
_rogue=0.0.0.0
echo -e "n=1\nwhile ! wget -q -O /tmp/hsts http://winhelp2002.mvps.org/hosts.txt ; do\n\t[ \$n -gt 5 ] && break\n\tlet n+=1\n\tsleep 60\ndone\ngrep \"^0.0.0.0\" /tmp/hsts | grep \"^0.0.0.0\" | grep -v localhost | awk '{print \"$_rogue\\\t\"\$2}' | tr -d '\\\015' >/tmp/dlhosts\nrm /tmp/hsts" >/tmp/wh
sh /tmp/wh &
sleep 4
# Create a sorted Adblock file for both IPv4 & IPv6
rm /tmp/adhosts
H_MERGE=/tmp/adhosts
H_ORIG=/tmp/dlhosts
sort $H_ORIG | uniq | grep "^0" | sed "s/0\.0\.0\.0/::/g" >> $H_MERGE
sleep 2
sort $H_ORIG | uniq | grep "^0" >> $H_MERGE
sleep 2
# Restart DNSMasq
restart_dns


Additional DNSMasq Options...

# Adblocking hosts file for IPv4 & IPv6
addn-hosts=/tmp/adhosts

_________________
Home Network on Telus PureFibre - Wired GigaBit Backbone
| SSH | DDNS | DNSCrypt-Proxy | DHCP/Static IPs | Ad-Blocking |
| USB Storage - Scripts Only | VLANs/BRs | WiFi - APs/VAPs |
| OpenVPN-Client | YAMon3 | Telus-IPv6 | ebtables | ip6tables |

Gateway R7000 - KONGAC 36410M Release 2018-07-28
Wireless R7000 - KONGAC 35550M Release 2018-03-28

______________________
YAMon 3.0 | Ad-Blocking for DD-WRT
DDWRT 60-day Timeline/changelogs
Kong Builds | DD-WRT Beta Builds
CloneVince's copies of Kong's Arm Firmware
jcdole
DD-WRT Novice


Joined: 13 Jun 2015
Posts: 29
Location: South-West France

PostPosted: Fri Mar 02, 2018 19:03    Post subject: Reply with quote
jcdole wrote:
Hello.
Seems there is a problem whith one url in the sript gen_host.sh.
The URL "http://jansal.googlecode.com/svn/trunk/adblock/hosts" is no longer usable and I cannot download from the new project which has been exported to GitHub: https://github.com/lewisje/jansal.
Any help is welcome.


Another problem cannot download anymore from :

Code:
Mar 2 17:03:34 troll-router user.notice root: gen_host: Downloading host entries from https://raw.githubusercontent.com/lewisje/jansal/master/adblock/hosts (attempt 3)...
Mar 2 17:03:34 troll-router user.notice root: gen_host: Download failed [http code : 000 - ret_code : 77 ]...

Mar 2 17:04:19 troll-router user.notice root: gen_host: Downloading host entries from http://www.malwaredomainlist.com/hostslist/host.txt (attempt 3)...
Mar 2 17:04:20 troll-router user.notice root: gen_host: Download failed [http code : 404 - ret_code : 0 ]...


Trying with wget in place of curl give same error.

Doing the same download from my computer ( opensuse leap 42.3 ) under konsole does not give errors.

Any help is welcome.

_________________
Netgear R6300v2 rev30082-Linux Opensuse Leap 42.3
jcdole
DD-WRT Novice


Joined: 13 Jun 2015
Posts: 29
Location: South-West France

PostPosted: Fri Mar 02, 2018 19:24    Post subject: Reply with quote
jcdole wrote:
jcdole wrote:
Hello.
Seems there is a problem whith one url in the sript gen_host.sh.
The URL "http://jansal.googlecode.com/svn/trunk/adblock/hosts" is no longer usable and I cannot download from the new project which has been exported to GitHub: https://github.com/lewisje/jansal.
Any help is welcome.


Another problem cannot download anymore from :

Code:
Mar 2 17:03:34 troll-router user.notice root: gen_host: Downloading host entries from https://raw.githubusercontent.com/lewisje/jansal/master/adblock/hosts (attempt 3)...
Mar 2 17:03:34 troll-router user.notice root: gen_host: Download failed [http code : 000 - ret_code : 77 ]...

Mar 2 17:04:19 troll-router user.notice root: gen_host: Downloading host entries from http://www.malwaredomainlist.com/hostslist/host.txt (attempt 3)...
Mar 2 17:04:20 troll-router user.notice root: gen_host: Download failed [http code : 404 - ret_code : 0 ]...


Trying with wget in place of curl give same error.

Doing the same download from my computer ( opensuse leap 42.3 ) under konsole does not give errors.

Any help is welcome.


Putting -k in the curl command :

previous :

Code:
(curl -o "$TEMP_FILE" --silent --write-out '%{http_code}' --connect-timeout 60 --max-time 120 "$URL" > "$HTTP_CODE") & DOWNLOAD_PID=$!


New :

Code:
(curl [color=red][b]-k[/b][/color] -o "$TEMP_FILE" --silent --write-out '%{http_code}' --connect-timeout 60 --max-time 120 "$URL" > "$HTTP_CODE") & DOWNLOAD_PID=$!


solve the first error above.

Still error on
Code:
http://www.malwaredomainlist.com/hostslist/host.txt

_________________
Netgear R6300v2 rev30082-Linux Opensuse Leap 42.3
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 2050
Location: London,UK

PostPosted: Fri Mar 02, 2018 19:34    Post subject: Reply with quote
very simple add blocking script that allows multiple hosts to be added...
add this to startup script:

wget -qO /tmp/mvps http://winhelp2002.mvps.org/hosts.txt
wget -qO /tmp/someonewhocares http://someonewhocares.org/hosts/zero/hosts

stopservice dnsmasq && startservice dnsmasq

Services/DNSMasq/Additional DNSMasq Options:

addn-hosts=/tmp/mvps
addn-hosts=/tmp/someonewhocares


you can add more lines in the script and add lines in additional DNSMasq options too i just use those 2...

CURL command works on some routers but it's stripped from others, so not many routers support it... you have to check this for yourself...or there are some bugs with it and its not working...

_________________
Atheros
TP-Link WR740Nv4 .......DD-WRT 33986 BS (AP,NAT,AD Blocking,Firewall)
TP-Link WR1043NDv2 ------DD-WRT 36154 BS (AP,PPPoE,NAT,AD Blocking,AP Isolation,Firewall)
TP-Link WR1043NDv2 ------DD-WRT 36410 BS (AP,NAT,AD Blocking,Firewall,No Wi-Fi)
TP-Link WR1043NDv2.......... Gargoyle OS 1.10 (AP,NAT,QoS,Quotas)
Qualcomm/IPQ8065
Netgear R7800 ------------DD-WRT 36500M Kong (AP,NAT,AD-Blocking,AP Isolation, Firewall,DNSCrypt x2)
Broadcom
Netgear R7000 ---------DD-WRT 36410 Kong (AP,NAT,AD-Blocking,AP Isolation, Firewall,DNSCrypt x4)
Others
Netgear ProSAFE-GS105Ev2 ....(LAN Switch)


Last edited by Alozaros on Fri Mar 02, 2018 19:55; edited 1 time in total
Goto page Previous  1, 2, 3 ... , 12, 13, 14  Next Display posts from previous:    Page 13 of 14
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware 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 can attach files in this forum
You can download files in this forum