Raspberry Pi Uncategorized

Pi-hole Improvements: More Ad Domains And A Better Script

The Pi-hole blocks ads for every device on your network by re-routing known ad-serving domains to a fake Web server.  I made a new branch of the project, which I will eventually merge back in with the master project.  This branch has additional domain sources (306,000), and a better script that uses a loop so additional source URLs can be added in much easier.

In addition, I also added a list of sites that have domain blacklists, which I hope to add into the script.  Some of them need a lot of formatting, but there are many to look at.  Eventually, the Pi-hole can also be used to block malware domains, phishing domains, spam domains, and anything else you don’t want to see or visit while using the Internet.

The script is meant to for the Raspberry Pi, but can be modified to run on other UNIX-like systems.

10 replies on “Pi-hole Improvements: More Ad Domains And A Better Script”

Hey, I’m having some problems with the priceline app on both iPad and iPhone. I’ve definitely narrowed it down to the Pi as when I change the DNS to the default it starts working again. The problem is that it doesn’t show the hotel photos. I believe I have narrowed it down to the domain using the real time log. I’ve added that to a whitelist.txt in the etc/pi folder, but it keeps redirecting that domain to Any ideas? I’ve tried putting the domain in every way I could think of in the whitelist.,,, etc. to no avail.

You need to run the gravity script again in order for the whitelist entries to be parsed. Also, did you restart dnsmasq? It needs to be restarted after changing entries since the results are cached.

Could you send me the output of this command:

cat /etc/dnsmasq.d/adList.conf | grep bstatic

If the command doesn’t return anything than it should work (because it did not find any entries).

As a last resort, you could simply search for bstatic in the adList.conf file and manually delete them and then restart dnsmasq .

Also, if you can’t get the whitelist.txt to work, please let me know as I would need to look into it more.

We had some similar problems with xkcd, which for some reason was on one of the lists that gets downloaded.

When i run that command i get “address=/”

I’ve rerun the gravity script and restarted the dnsmasq. When the script is running it lets me know “whitelisting x domains” x being equal to the amount I have in the whitelist.txt file, but still not working.

Run that command again after running the script. If it gives the same result, I may need to look at why it doesn’t remove that site.

In the meantime, you could just manually delete that line from the /etc/dnsmasq.d/adList.conf:


Has something changed with the script recently? My Pi ad blocker was working GREAT for several months, faithfully and quickly serving up nothingness where ads used to be. Then we had a power outage, and apparently something got scrambled as it was no longer blocking ads (going to secondary DNS), and rebooting showed a couple of errors. I thought “no problem, I’ll just build it again”, and I reformatted my SD card, imaged it with Raspbian, ran the install script, everything looked OK as it was building with no errors, but now when I set the Pi as the DNS it either takes an incredibly long time to load a page or it will not load at all, and I’ve tried it on several different computers on my network. I’ve tried rebuilding it 5 times now with two different SD card with the same result, even looking at the script you have posted and followed along with it. Any ideas? BTW, I’m only slightly more than a novice at Linux scripting. Thanks for any help!

I am also having the same issue. Anyone figure it out? Seems to work and block ads, but it’s incredibly slow.

Actually, the mahakla ad list just had a huge update, which pushes the compiled list to 900K entries, which seems to bentos large for the Pi.

I am already working on a method to improve this. In the meantime, if you just comment out the line with the mahakala URL, and then run the gravity script again, he lost will be smaller and more manageable. However, it may miss a few ads that were since a bunch come from that list.

I haven’t tested it yet, but it is supposed to be much faster if you format the file as a hosts file and not a damasq one. But I haven’t made time to fully test it yet.

Thank you very much for the reply Jacob, and thanks a lot for putting all this together and making it so simple! Guess it’s time for me to learn how to edit a script! 🙂

Done, lightning fast again! But you’re right, there are a lot of ads that it misses now. I wonder if there is a way we can revert to the Mahakla list before the latest update. I wish I wouldn’t have already formatted the SD card I was using before, maybe I could have copied that file over to the new install.

There isn’t a way to revert the list, as it just creates a brand new one each time you run the script, which won’t be as much of an issue in the next release.

Since the list is so large, I am experimenting with using a hosts format file, which is supposed to perform much better. The Pi will never be the fastest machine on the planet, but I think with some modifications, it can run a lot better.

Leave a Reply