Jump to content
Compatible Support Forums
Sign in to follow this  

BIND as a replacement for Windows Hosts file for the purpose of Ad Blocking

Recommended Posts

Was re-reading APK's Host file + dialup problems and started tinkering again. Would have done this


sooner but I haven't used internet at home since 1998! Only at work or when I visit my paren'ts. Well I


decided to hook up my cell phone to the 'net and surf, and what do I find but tons of ads! This


immediately made me think of APK and the hosts file. I've never like the Hosts file and I've always


wanted to use DNS instead.....the problem was making it easy for a home user to install/configure and


understand. So I surfed around for easy ways for Windows users to use BIND and I found it!


It is:



TreeWalk DNS Server



This is basically BIND but makes it easier to configure for Windows users. It sets you up locally as a


caching DNS server and then forwards DNS requests to DNS servers on the internet. You modify your


dial-up or NIC settings to point to, since you are the DNS server for your zone.


All you have to do next to get it to work is go into the TreeWalk DNS Control Panel and Start the


service.....and your done!


For me using TreeWalk was faster than using my ISP's DNS, most likely due to BIND than anything else.




Now if you want to block banner ads:


Stop your DNS service via TreeWalk DNS Control Panel

Go to \windows\system32\dns\etc


Edit named.conf with notepad and add the following line to the bottom of the file


zone "sped.atdmt.com" { type master; file "blockads"; };


Where sped.atdmt.com = what site you want to block

Where blockads = a file in your \etc directory where you will add the zone info for that site.


Ok, so once you have that line added, save the file and now create the blockads file.


Now within the blockads file, add these lines:


$TTL 24h


@ IN SOA localhost. root.localhost. (

2003052800 86400 300 604800 3600 )


@ IN NS localhost.

@ IN A

* IN A




So now whenever you wish to block sites. Simply add another

zone "sped.atdmt.com" { type master; file "blockads"; };

line to the end of your named.conf file (changing the site name of course) and you'll be good to go!



Go here to convert your Hosts file into BIND config: http://pgl.yoyo.org/adservers/hosts2bind.php



Some benefits of using this method over Hosts, is that you no longer have to worry about huge hosts


lists that seem to make dial-up flaky, (probably due to Hosts file not being designed for such long


lists!) and you can easily carry the file over to any Linux system.

Share this post

Link to post
Share on other sites

Alright, I almost have a way for the Windows DNS users out here to do a bulk load, but I need a way to limit the domains used to just the domains, and not have any host/sub domains in the file (you don't want to have a zone for each subdomain, as that's wasted space). I have a list of domains, but I would like to trim it. I figure common denominator would be to trim two periods from the end (such as test.fastclick.net and ad1.fastclick.net would be left with fastclick.net when trimmed from the right end). So, any ideas?

Share this post

Link to post
Share on other sites

I believe if you remove the last line in your null zone file (blockads file in my post above), that will fix your problems.


* IN A


The wildcard blocks hostnames and subdomains of that domain....so removing this line hould allow the @ IN A line to block that single domain.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this