The purpose of the tutorial is to setup an ads blocking using Bind9 DNS Server. Tutorial is divided into 2 section: Setup Pixelserv and Setup AdBlock script for Bind9.

1. Setup Pixelserv

Pixelserv is a super minimal webserver, it’s one and only purpose is serving a 1×1 pixel transparent gif file. We will redirect web requests, for adverts, to our pixelserv (running in the same bind9 server).

Install Pixelserv

cd /usr/local/bin/
curl > pixelserv
chmod 755 pixelserv

We now need a simple init script for starting/stopping pixelserv, as /etc/init.d/pixelserv.

#! /bin/sh
# /etc/init.d/pixelserv
# Carry out specific functions when asked to by the system
case "$1" in
echo "Starting pixelserv "
/usr/local/bin/pixelserv &
echo "Stopping script pixelserv"
killall pixelserv
echo "Usage: /etc/init.d/pixelserv {start|stop}"
exit 1

exit 0
chmod 755 /etc/init.d/pixelserv

Add pixelserv to startup

update-rc.d pixelserv defaults

Run pixelserv

/etc/init.d/pixelserv start


2. AdBlock for Bind9

Create new file, /etc/bind/

curl "" | sed 's/\/etc\/bind\/nullzonefile.txt/g' > ad-blacklist

Make it executable

chmod +x

Execute to download adservers file


Verify file content, make sure the path is changed from:

zone "" { type master; notify no; file ""; }; to zone "" { type master; notify no; file "/etc/bind/nullzonefile.txt"; };

Create adblock zone file, we named it as nullzonefile.txt

$TTL    86400   ; one day  
@       IN      SOA (
                    86400 )          
                A       $YOUR_DNS_SERVER_IP 
@       IN      A       $YOUR_DNS_SERVER_IP
*       IN      A       $YOUR_DNS_SERVER_IP

Reload bind9 configuration

rndc reload

Test your DNS Server

dig @localhost

Should returned your own server ip address.

The Best Ad Blocking Method

Using BIND to reduce ad server content

Incoming search terms:

  • bind9 block ads
  • adblock with bind9
  • bind dns ad blocking
  • bind9
  • bind9 adblocker liste
  • configure bind to block ads
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1830 SdN3hy0oAot8LSGTZUFvm-EeD_IL353w56o1JeiRUlXzWljLXzIBS2J6U56fv_il 33ea186913f68b87bd6573ba5cc594eb0387e44e&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1839 ibrtdoRSwW28TMVD7P3YmP0a-Aq-HE0XSF0wRAnO9l0rYAWuQs__rl2W8MVYWD0r 6ca9d4cf762e707319ae0a4e311d390ab9938e5c&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme