What's new

AdBlocking with combined hosts file

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

for some reason I can't get the second method to work.

This is show in the System log:

failed to load names from /tmp/mnt/PNY/hosts/hosts.blocked: No such file or directory
 
I don't know if any of is aware of this but the adblock scripts here do work
without entaware.
 
Ive been experiencing issues with this.

I used the advanced method to get it working.

It does work, but I am noticing that sometimes my DNS requests to sites not in the blocked hosts file are not being resolved. Sometimes requires a refresh of the browser to actually get the site to load.

Tested in both Chrome and Safari.

Scripts are installed on a RT-AC66U.

If there is no solution to this, can someone tell me how to disable it and I'll go back to using the AdBlock Plus browser plugin. Dont want to do that but its very frustrating and time wasting when legitimate DNS queries dont resolve.
 
these 2 lines are bad news remove them

address=/0.0.0.0/0.0.0.0
ptr-record=0.0.0.0.in-addr.arpa,0.0.0.0

the addn-hosts lines if you remove will disable it.
 
these 2 lines are bad news remove them

address=/0.0.0.0/0.0.0.0
ptr-record=0.0.0.0.in-addr.arpa,0.0.0.0

the addn-hosts lines if you remove will disable it.
Hi Chrysalis,
Could you elaborate on why these lines are bad news please.
Both lines were added to solve specific problems, as discussed earlier in this thread.
 
I cannot remember the exact nature of how it broke, but basically when I first copied this guide I had the address line in place and had some dns issues caused by dnsmasq on my router, when I removed the lines, it reverted to normal behavior and have seen no ill affect with the filtering.

Also reading the dnsmasq documentation, doesnt correlate with how those are used.
 
does this look like "chmod a+rx /jffs/scripts/*" ?
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    79 KB · Views: 606
does this look like "chmod a+rx /jffs/scripts/*" ?
If you are referring to "Custom Commands > Execute" then the answer is No.

You want "Properties > Permissions" and check that "R" and "X" (and "W" if you want) are ticked for Owner, Group and Others. Or you could just set "Octal" to "0777".

But I can see from the "Rights" column in the background of your picture that they are already set correctly. :)
 
does this look like "chmod a+rx /jffs/scripts/*" ?
You can see the 'Rights' column in the background....everything is set to "777" which is what happens if you are transferring from a Windows system (make sure the files are in Linux format and not DOS/Windows format).
 
If you are referring to "Custom Commands > Execute" then the answer is No.

You want "Properties > Permissions" and check that "R" and "X" (and "W" if you want) are ticked for Owner, Group and Others. Or you could just set "Octal" to "0777".

But I can see from the "Rights" column in the background of your picture that they are already set correctly. :)

then something went wrong :S , i sat everything and still not getting ads blocked
 
You can see the 'Rights' column in the background....everything is set to "777" which is what happens if you are transferring from a Windows system (make sure the files are in Linux format and not DOS/Windows format).

i didn't transfer anything from windows o_O
yeah i confirm everything is sat to 0777
 
how can i disable it when i dont want it ??
To temporarily disable the hosts files remove the following, see post #1 if you are unsure which method you use:

1. Standard method (the original)
in /jffs/configs/dnsmasq.conf.add remove this:
Code:
address=/0.0.0.0/0.0.0.0
addn-hosts=/tmp/mnt/sda1/hosts.clean
2. Advanced method
in /jffs/configs/dnsmasq.conf.add remove this:
Code:
# AdBlocking
address=/0.0.0.0/0.0.0.0
ptr-record=0.0.0.0.in-addr.arpa,0.0.0.0
addn-hosts=/tmp/mnt/sda1/hosts/hosts.blocked
addn-hosts=/tmp/mnt/sda1/hosts/blacklist.txt

And then restart dnsmasq (or reboot the router):
Code:
service restart_dnsmasq

If you want to entirely remove it because you have no need for adblocking reverse the steps as explained in post #1
 
Used Advanced Method w/ Merlin 378.55 not working kept on getting blacklist.txt & hosts.blocked not found but I know it's there. Tried post-mount fix didn't work either. If I restart service dnsmasq manually it loads my blacklist.txt and does block my custom list but I don't think the other lists are loaded so it doesn't block other ads.

I'll try again once there's a sure fix with new firmware. I enabled AdBlock Plus again in Firefox cnn.com and other sites load super fast those ads slow down web page loading.
 
Thanks for the scripts! I modified the "advanced" one as follow (AC68):

1) Put the content in wan-start, instead of service-start (which didn't work for me for some reason)
2) Never installed entware, therefore removed the "/opt/etc/init.d/rc.unslung start" line and modified all the /tmp/mnt/sda1/* references.
3) update-hosts.sh: Modified the middle portion like this:

Code:
# get hosts files and combine
wget -qO- \
"http://winhelp2002.mvps.org/hosts.txt" \
"http://someonewhocares.org/hosts/zero/hosts" \
"http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&startdate[day]=&startdate[month]=&startdate[year]=&mimetype=plaintext&useip=0.0.0.0" \
"http://www.malwaredomainlist.com/hostslist/hosts.txt" \
"http://hosts-file.net/ad_servers.txt" \
> $dir/temphost

# replace all 127.0.0.1 with 0.0.0.0 if any, grab only the first 2 parts (IP, hostname) of each line, and sort the combined entries
cat $dir/temphost | sed s/127.0.0.1/0.0.0.0/g | sed $'s/\r$//' | grep -w ^0.0.0.0 | awk '{print $1 " " $2}' | sort -u > $dir/temphost2

# remove whitelisted entries in temp and write final file, remove temp file
cat $dir/whitelist.txt | sed $'s/\r$//' | grep -vf - $dir/temphost2 > $dir/hosts.blocked

#remove temp files
rm $dir/temphost
rm $dir/temphost2

The reasons are
a) the entries in the 2nd wget aren't sorted against the entries from the 1st wget
b) some entries come with comments
c) different sites use different delimiters: yoyo.org etc use single space, malewaredomainlist.com uses double spaces, and hosts-file.net uses tab. So I use awk to grab only $1 (0.0.0.0) and $2 (hostname) and feed sort -u with only the "cleansed" entries.
 
@ChikkSpot I am aware of entware not needed. I am going to remove that later today.

Edit: Entware removed from post #1.
 
Last edited:
Tried post-mount fix didn't work either. If I restart service dnsmasq manually it loads my blacklist.txt and does block my custom list but I don't think the other lists are loaded so it doesn't block other ads.
That seems to be a path problem. Double check the location of the hosts.blocked and blacklist.txt and compare it to the entry in dnsmasq.conf.add file. Those need to be the same path as your USB disk.
 
Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top