-
Notifications
You must be signed in to change notification settings - Fork 150
Using AdBlock filters
This guide will help you setup advertisement filtering (similar to Adblock Plus) through your device. It is suggested to use in conjunction with a mobile device (such as an iOS or Android smartphone), as filtering a PC will cause performance loss due to hardware limitations on the embedded device. This guide uses privoxy (a proxy server) to capture and filter traffic from mobile devices.
This is optional. If you wish to configure router as transparent proxy, you need to bind static IP to chosen devices and add iptables rule, see Acting as transparent proxy for details.
First, install the necessary packages:
opkg install bash wget sed privoxy
Next, download and install the already prepared privoxy configuration file:
wget http://files.ryzhov-al.ru/Routers/adblock-plus/config -O /opt/etc/privoxy/config
Next, download and install the script that will convert Adblock Plus rules for use with our proxy:
wget http://files.ryzhov-al.ru/Routers/adblock-plus/privoxy-blocklist_0.2.sh
Mark the script as executable so we can run it:
chmod +x ./privoxy-blocklist_0.2.sh
Edit the script to include the Adblock Plus subscriptions that you would like to use. A list of subscriptions can be found on this page. You may also consult the Adblock Plus installation in your preferred browser for the subscriptions it uses. Find the URLS= line in the script and append the URLs of the subscriptions to it.
Next, download the subscription's filters and create the privoxy blacklist by running the script:
./privoxy-blocklist_0.2.sh
If you'd like to change the subscriptions (for example, to add a new subscription list) or update the existing subscriptions, you'll need to remove the old ones first:
./privoxy-blocklist_0.2.sh -r
If you're changing the subscription lists, edit the script as described in the instructions above to add/remove the subscription URLs as necessary. If you just wish to update the lists, no script editing is necessary. Then run the script to download the updated subscription filters and create a new privoxy blacklist:
./privoxy-blocklist_0.2.sh
/opt/etc/init.d/S24privoxy start
At this point, you should have a working proxy server on 3128 port that filters advertisements from web pages loaded on a client device. Privoxy will be started automatically on every boot.
Configure device to use proxy server on 3128 port and check the client to ensure that advertisement filtering is working as expected!
While using transparent mode, no any configuration is needed on client device.
Determine the device you would like to apply advertisement filtering to. You will need to apply a static IP for this device - you can do so by accessing your router's web interface. Next, add a rule to iptables to intercept traffic from the device and pass it through privoxy for advertisement filtering:
iptables -t nat -A PREROUTING --source [the static IP address of device] -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
(Ensure you replace [the static IP address of device] with the static IP address you assigned in the previous step.)
Reboot the router, and check the device to ensure that advertisement filtering is working as expected!
- Original Privoxy script to transform AdBlock subscriptions - https://github.com/Andrwe/privoxy-blocklist
- Discussion thread on SNB (asuswrt-merlin firmware) - http://www.snbforums.com/threads/how-to-adblock-plus-filters-right-on-router.9449/