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!

Help?

Just wondering if somebody might be able to help me. I am trying to use this but it doesn't seem to work. I am using Asus AC66U using Merlin FW. I formatted a 1gb USB disk EXT2. I installed entware using the script. I followed all the instructions but I am not blocking ads. I am wondering if my issue is because my /mnt/ folder has /USB_DISK/ and not /SDA1/ like the scripts call out? I am extremely new to Linux. I have all the tools installed (SCP and PuTTY).

As somebody else pointed out earlier, I am going through the scrips and "Executing" them via WinSCP. Everything appears to work (no errors reported) except for when I execute "dnsmasq.conf.add". First I got permissions issues, so I chmod to 777. Now I am getting

Code:
Command '"./dnsmasq.conf.add"'
failed with return code 127 and error message
./dnsmasq.conf.add: line 2: addn-hosts=/tmp/mnt/sda1/hosts.clean: not found.
 
Last edited:
Just wondering if somebody might be able to help me. I am trying to use this but it doesn't seem to work. I am using Asus AC66U using Merlin FW. I formatted a 1gb USB disk EXT2. I installed entware using the script. I followed all the instructions but I am not blocking ads. I am wondering if my issue is because my /mnt/ folder has /USB_DISK/ and not /SDA1/ like the scripts call out? I am extremely new to Linux. I have all the tools installed (SCP and PuTTY).

As somebody else pointed out earlier, I am going through the scrips and "Executing" them via WinSCP. Everything appears to work (no errors reported) except for when I execute "dnsmasq.conf.add". First I got permissions issues, so I chmod to 777. Now I am getting

Code:
Command '"./dnsmasq.conf.add"'
failed with return code 127 and error message
./dnsmasq.conf.add: line 2: addn-hosts=/tmp/mnt/sda1/hosts.clean: not found.

dnsmasq.conf.add is not a script. It's just a text file that gets blindly appended at the end of the main dnsmasq.conf file.
 
I am wondering if my issue is because my /mnt/ folder has /USB_DISK/ and not /SDA1/ like the scripts call out? I am extremely new to Linux. I have all the tools installed (SCP and PuTTY).
If /tmp/mnt/USB_DISK/ is your path then you need to edit the path entries (/tmp/mnt/sda1/) in
- /jffs/scripts/post-mount (2x)
-/jffs/configs/dnsmasq.conf.add (1x)
-/jffs/scripts/update-hosts.sh (1x)

When you've done that reboot or run command in terminal:
Code:
sh /jffs/scripts/update-hosts.sh
 
Last edited:
If /tmp/mnt/USB_DISK/ is your path then you need to edit the path entries (/tmp/mnt/sda1/) in
- /jffs/scripts/post-mount (2x)
-/jffs/configs/dnsmasq.conf.add (1x)
-/jffs/scripts/update-hosts.sh (1x)

When you've done that reboot or run command in terminal:
Code:
sh /jffs/scripts/update-hosts.sh

Great, thanks. That did the trick.
 
Thanks for the guide it's working great!

PS I didn't need to install entware because all of the commands (wget, grep, sort and sed) were available already.
 
Local language ads are not really covered by the downloaded list.
Where should I put my custom host entries?
 
Local language ads are not really covered by the downloaded list.
Where should I put my custom host entries?
Just add another entry to /jffs/configs/dnsmasq.conf.add
Like so:
Code:
address=/0.0.0.0/0.0.0.0
addn-hosts=/tmp/mnt/sda1/hosts.clean
addn-hosts=/tmp/mnt/sda1/your-own-hosts-file
And place your-own-hosts-file in the same directory as hosts.clean.
Then restart dnsmasq
Code:
service restart_dnsmasq
 
Just wanted to add to the previous post.
If you add another hosts file make sure it is set to reslove to 0.0.0.0 and not 127.0.0.1
 
What gets displayed in place of the advert using this method, is it the bog standard page cannot be displayed message?
 
What gets displayed in place of the advert using this method, is it the bog standard page cannot be displayed message?
Depends on the size or html or even your browser. As an example, this forum will not show any ads at all (sorry smallnetbuilder!). You'll have a white header that has the size of the missing ad size. Piratebay is obnoxious with its ads, it will show several page not found fields.
On the majority of websites though you will not see any indication that ads are filtered. And that is just fantastic!
 
Does this also work on in video youtube ads?

if it does looks very interesting as software adblockers are resource hogs.
 
Last edited:
Does this also work on in video youtube ads?

if it does looks very interesting as software adblockers are resource hogs.
You mean ads embedded in Videos? Most likely not.
Try it out, you'll be surprised...
 
I am already testing in firefox, adblock plus turned off, confirmed working via some manual nslookup commands.

Currently not seeing ads in youtube vids but this is possibly due to cache.

I am seeing google ads on pages.

Plus pages where ads are blocked still do still slow down as the browser still tries to make a connection (to 0.0.0.0), so is slower than when stopping via adblock plus..

However I do still think this is decent as it affects all apps automatically, plus like you said all devices.
 
Read my first post again, there is a link to Adblocking with Lighttpd.
This will help with the timeout.
Remember to clear the cache in your browser as well.
 
I am not seeing timeout issues, the delay isnt long, just is a delay of 200ms or so for the fact it even tries to make connections.
 
I added lighttpd as in theory it should still help as a item to load is better then a 404 for caching. Which in theory should stop the connection attempts although its not helping on this site, I will provide more feedback later.

Accessing the router via https is very slow tho.
 
Accessing the router via https is very slow tho.
I have noticed this as well. Went back to http and have a seperate always-on linux server in my network handle the pixelserving. Works like a charm.
Plus I can log all the 'misguided' traffic and adjust my settings.
 
I think a good idea is to assign a 2nd lan ip to the router, and have lighttpd only listen on that ip address.

Whether that works depends if the GUI http service listens on * or just the local lan ip.
 
If you can figure this out and post it we'll gladly use it...
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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