Blocking Ads with dnsmasq

Posted on January 22, 2015 under dns

For a while I have an OpenWRT router installed, running a Linux to which I have full root access. One of the services on this devices is a DNS resolver. I use this to block all ads that websites try to sneak into my view.

To accomplish this I combine block lists from multiple sources and configure the resolver to redirect them into a black hole. The configuration for dnsmasq is generated with the following Makefile.

You can execute it as follows: make SERVER=192.168.1.1 BLACKHOLE=192.168.1.234, if all requests should be redirected to 192.168.1.234 and your router is reachable at 192.168.1.1.

(based on PiHole).

To improve the performance, you can choose to download multiple files in parallel by specifying another parameter -j, use -j4 to run four tasks in parallel.

I hope this helps some people to make the web a faster place!