Ad Blocking with DNS

Easy to ad block with your own DNS server if you don’t want to trust adblock or other plugins.

1 – you need a web server to host a blank image

2 – Get blacklist

Get the blacklist from

Choose for the bind 8 config format.

I had to change the file so that the records read like this:

zone "" IN { type master; notify no; file "/etc/bind/"; };

by adding the “IN” between the domain name and the “{ type master ….” part. Use your vi-skills for this.

Give this file a easy name, like ‘blacklist’. Now create a line in /etc/bind/named.conf.local:

include "/etc/bind/blacklist";

Create the null zone file

Create a file /etc/bin/ with the following contents:

$TTL    86400   ; one day

@       IN      SOA (
            2002061000       ; serial number YYMMDDNN
            28800   ; refresh  8 hours
            7200    ; retry    2 hours
            864000  ; expire  10 days
            86400 ) ; min ttl  1 day


@               IN      A
*               IN      A

and replace by your internal domain name and replace by the name of your web server. The above format allow for the use of wildcards. This means that you do not have to care about the subdomains.

Restart bind (Ubuntu version)

service bind9 restart

2 is copied from here for posterity:

3 – use a different DNS source if you want

If you want to use a different DNS server (say you don’t trust your ISP or Google to know every site you query) you can find others here:

And then in /etc/bind/named.conf.options add the forward to the dns servers:

 forwarders {;;;

Leave a Reply

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