DD-WRT on the Buffalo WZR-HP-G300NH – Using privoxy for ad blocking

In my previous post I described setting up optware and USB storage on DD-WRT on the Buffalo WZR-HP-G300NH. To recap, I am running the latest official Buffalo DD-WRT release v24SP2-MULTI (07/15/12) std – build 19484 on the v1, A0A3 h/w version of this router. One of the things I wanted to try out was setting up privoxy as an ad-blocking proxy on the router. In this post, I will explain how I have setup privoxy on my router and how I used some additional scripts to enhance the built-in filtering list in privoxy.

Now, one  question to ask yourself before you set out to do this is – do you really need an ad-blocking proxy? The reason this question is valid is because if you use browsers such as Chrome or Firefox, extensions like AdBlock Plus do a fantastic job of blocking ads. The issue is when you cannot use these browsers – this is especially true on mobile platforms where you may not as much of a choice.

Installing privoxy is pretty straightforward once you have optware running as described in my previous post. Just run opkg install privoxy to install it. Privoxy has very good documentation which you can use to set it up as desired. I changed the default configuration to have no log files, listen to any incoming requests on port 8118 and verified everything was working as expected by setting the proxy in my desktop to 192.168.11.1:8118. Once this was working, I wanted to check if I could make this a transparent proxy and also if I could import an adblock list like easylist or fanboy to add to the privoxy blocking configuration.

A transparent proxy is one where the client needs no additional configuration. To the client, it appears like it is directly connected to the Internet while the traffic is silently directed through the proxy under the covers. The advantage is that clients need no configuration to take advantage of the proxy. To have a transparent proxy in dd-wrt you can follow either of the methods listed here. Unfortunately, neither of these methods seem to work well in this build of dd-wrt. I haven’t had the time to dig to find out why but basically clients are unable to connect to the Internet at all when transparent proxy is enabled with either method. For now, I have reverted to having the clients configure the proxy explicitly.

Ad block lists like easylist or fanboy are used with popular adblocking extensions like adblock plus. I wanted to use them to populate the privoxy configuration since these lists are comprehensive, actively maintained and widely used which means that they are also highly effective. prixovy config files are a different format from these lists. A search for scripts to convert from the adblock list format to privoxy configuration lead me to this script. I ran this on my Ubuntu VM to obtain the action file to be used with privoxy, populated that in my /opt/etc/privoxy folder on the router and added it to the configuration file. Unfortunately, the problem that I ran into was that the CPU load caused by this block list is too heavy for the router. Browsing became very visibly slower with this privoxy configuration and in addition the load factor on the router was consistently high when this filter list was enabled. As a result, I have disabled this configuration and stuck to the base privoxy configuration in addition to some custom actions in user.action file.

Finally, here is my init.d script for privoxy:

#!/bin/sh

case "$1" in
    start)
        /opt/usr/sbin/privoxy --pidfile /var/run/privoxy.pid /opt/etc/privoxy/config
    ;;
    restart|reload|force_reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
    ;;
    stop)
        kill `cat /var/run/privoxy.pid`
        rm /var/run/privoxy.pid
        killall privoxy
    ;;
    *)
        echo "Usage $0 start|stop" >&2
        exit 3
    ;;
esac

1 Reply to “DD-WRT on the Buffalo WZR-HP-G300NH – Using privoxy for ad blocking”

  1. Hey Ram

    Thanks for this. It helped me write the Privoxy section of a huge DD-WRT guide that I just wrote! It covers everything from the basics to more in-depth setup and optimisation. Would love to have your feedback if you’ve got some time.

    Thanks
    Peter

Leave a Reply

Your email address will not be published. Required fields are marked *