Raspberry Pi Uncategorized

A New, Easy Installation Method For The Ad-blocking Pi-hole

The Pi-hole blocks ads at before they get to your device and can speed up your network at the same time.  It’s now even easier to install (a forked) Pi-hole powered and automated by DietPi–a slimmed down, optimized version of Raspbian.

This burnable SD card image will give you essentially the same Pi-hole created by using the automated installer for Raspbian, but has some benefits/differences that I will explain below.  Before I do that, you probably want to know how to install it.

Download The DietPi Image Preconfigured As A Pi-hole

  1. Download this DietPi .img from Sourceforge, which is preconfigured as a Pi-hole
  2. Burn the image to your SD card (Windows instructions / OS X instructions / Linux instructions)
  3. Plug it into your Pi and boot it up
  4. Follow the on-screen instructions to set a static IP address
  5. Run dietpi-update  to updated to version 86, which fixes a small bug with the Web interface
  6. Change your DNS server for any device that you want to utilize the Pi-hole (or change the setting on your router, which is more advanced and something I can write up later)


After you have burned the Pi-hole image to your SD card and have booted up your Pi, login with the username root with the password dietpi.  Follow the on-screen instructions until you get to the IP address settings window.

You will be prompted to create a static IP address, which you should do.  You will be able to copy your current settings and use them as the static address, which will be easiest for most users.


Choose the adapter to change.  It would be best to use Ethernet as the Pi-hole should be plugged directly into your router.


For the easiest setup, just copy the DHCP settings and use them for the static address.  You can change the address as you see fit if you know about your network.  It is important for the Pi-hole to have a static address, however, since it is a server.  Not setting one can cause your Pi-hole to break at some point in the future.


Save your settings and exit.  Your Pi will then update, install the Pi-hole, and restart.  Then, all you need to do is change the DNS server of any device you want to have ads blocked on.

Benefits/Differences Of This Install Method


  1. It is easier to install and configure
  2. It runs faster than Raspbian since it is only running essential services
  3. It installs the Pi-hole Admin Web Interface by default found at <your Pi’s IP addres>/pihole/index.php


  1. It doesn’t install the exact same Pi-hole created via the automated installer
  2. It uses Apache instead of lighttpd
  3. The default page that ads get redirected to says “Blocked by Pi-hole.” instead of just a blank page


I used my original Pi-hole for many months without issue and never had a problem.  I switched over to the DietPi version a few weeks ago and as far as I can tell, they run the same.  So essentially, it just comes down to how you want to install it and if you are planning on doing anything else with your Pi.

I still need a way for users to easily update their script or other components of the Pi-hole if changes are made.  I have a method to do this but I need time and money to do it…

Development Plea

…which leads me to my plea.  Both the Pi-hole and DietPi are powered by your donations, so if you like either project, please show your appreciation below.

Pi-hole: Network-wide ad-blocking

DietPi: Optimized version of Raspbian


104 replies on “A New, Easy Installation Method For The Ad-blocking Pi-hole”

Not yet. Right now it’s just for viewing stats. Eventually, I’d like to be able to completely manage the Pi-hole from the Web interface.

OK 🙂

And the statistics; do they work? I just installed the image but dns queries, dns requests etc stay ‘0’, only the number of 1,6 million domains is shown.

It should be working–it has been showing my stats correctly; I check it once a day or so.

Have you been browsing the Web with a device using the Pi-hole as its DNS server? If not, no log entries would have been generated yet.

Yep, I have it sat as my DNS server in my Router, so that all clients use it. It seems to be working fine (just like the regular pihole setup I had before): all adds are blocked everywhere, on all devices.

But the stats are not updating it seems, or is there any lag build in?

Strange. I’ll take a look when I get home tonight and see if I can figure out why it might not be updating.

Just started showing numbers 😉 seems that maybe it buffers somehow? Of maybe just cache. Anyways; looks awesome, hopefully you’ll get whitelisting/updating etc working, would be even more awesome 🙂

PS. Just donated, cheers!

Thanks for the donation! I appreciate that very much.

I know DietPi does have some sort setting for log files to try to improve overall system performance, so it might have to do with that. I don’t recall exactly what it was, but good to know.

I guess… because I just did a reboot, and all are back at 0 right now 🙂 I guess they’ll show up later again.

It appears there is a bug with how DietPi is handling the logs. I am working with the author and will let you know. Most likely, the fix will be able to be applied by running dietpi-update once a release is available.

Hi! It’s not working correctly 😉 After a reboot, the stats were gone, and after an hour or two they started to work again, however, after an evening + night, they still show the same numbers. It seems stuck or something… If there’s anything I can do to help, let me know!

Hey love the new easy way 🙂
But I have one question and one problem ^^
First the problem is that I can’t see the web interface, it always tells me there is no /pi-hole/index.php on the raspberry pi :/ is it possible to run the setup again? Maybe it’s not completed :/
The question I have, is it possible to add a custom domain for blocking? I used yor older versions to block Facebook with my raspberry pi, it didn’t work That way on this version ;/
Hope you can help me.
Keep up the great work
Greetings carsten

It should be not pi-hole/index.php–no dash between pi and hole, and where is the IP of your Pi.

If you create /etc/pihole/blacklist.txt and add your domain, it will be automatically applied when you run

Thanks, the web interface now works, i thinks it is a little bit missleading that in your instructions there is a “-” 🙂
But the blacklist.txt will not be added to the blocked list 🙁
How do i run the

I cannot find a typo in my post where there is a dash in the address. If you see it, let me know and I will fix it, but I did a ⌘F and did not find where I mention that.

Did you change your DNS server to be the Pi?

Jacob – I think the problem is that your CMS is adding the hyphen in the main text above (See attached screenshot):

The page works for me (with the hyphen removed) however it always shows zero in all fields. The DietPi is working fine as I can tell by looking at the logs manually, but the web page doesn’t pick the numbers up. This is with V87.

Strange. Thanks for pointing that out. I’ll have to try to figure out how to fix that…

Yeah, the Web interface isn’t as fast as I want it to be. It’s still a bit clunky despite looking pretty. I guess that can be expected for a part-timer on this project. I would love to do it full time if I could make enough doing it…

Thanks again. I’ll try to fix that weird issue with the address to the interface.

I’m not sure what went wrong i followed the steps for dietpi to the letter, once all restarted i’m getting an error along the lines of ‘Startpar: error starting service dnsmasq’ at least i think thats what it said sorry im not at home yet i will erase the microsd and start over

well i’m a linux basic user no idea were to find any logs sorry, so what i did was apt-get remove dnsmasq, then autoremove then apt-get install dnsmasq, and i just turned it back on today and no Fails weird, only fail i get now is the ntfs-3g kernel driver but that only concerns other uses for dietpi unrelated to pi-hole, seems to be working for now jacob

something’s not right instead of getting “Blocked by Pi-hole.” i get “It Works! The web server software is running but no content has been added, yet” while reading the automated installed the apache webserver says its assuming is this the norm?

Have u got this to work? i did a newinstall with pihole/dietpi image and also got this problem when it starts up ‘Startpar: error starting service dnsmasq and apache webserver says its assuming I think the dns is working but im not sure.

When i get my new sd card (i don’t trust the 1 i got with the bundle) i am going to try changing my routers dhcp settings to match jacobs as i have no other clue what to do. I will keep you informed on my progress

yea already done twice over win32diskimager was telling me 4.1-4.7MB/s write hence why i don’t trust it it’s supposed to be a class 10 i have a new 32gb ordered it should be here within next 2 days

Thank you. I installed it and it seems to be running. When viewing the interface I see no DNS requests at all;

I have configured router to give the IP to the DHCP clients. For fun I tried to hardcode the IP on Windows and IOS. Regardless there are no DNS requests.

nslookup seems to work and I got some DNS lookups. Wonder why it does not work in Chrome browser…

Any ideas? Thanks

I’m already on v87… After trying Safari on IOS it seemed to work. Then Chrome on IOS and Windows also seem to work. I need to test more and compare with Adblock. Thanks so far 🙂

So far I’m on 16% add traffic. I know this is of course just the DNS lookups, but I wonder what bandwidth that saved me. Amazing 🙂

Anyone know if there is a trusted public DNS server with adblocking that could be used on the road?

Hi, I just updated to v87 but the webinterface still says 0 for all stats, and I’m sure the blocker works cause all clients function fine and ads are blocked… :S

I’ll try it out on my B and see if I get the same issue. Maybe it has something to do with the model.

Hi, the webpage showed 1 ad blocked yesterday, and today is shows 34 blocked, 445 dns queries, etc… So it seems to be doing *something* but I have no idea if the stats are correct 😉

There should be another dietpi-update, that the author of the distro said fixes the stats. Try that.

I just setup DietPi a couple days ago, it seems to be great. However I just ran into an issue today where I have entire domains/websites blocked. All I get is the “blocked by Pi-Hole” page when I try to go to certain sites. I went in and created a whitelist at /etc/pihole/, added the sites to it, rebooted, but still nothing. It seems to have some content filter setup in it beyond just ads if it’s blocking entire websites, a lot seem to be porn based, but even non porn sites like gambling and casinos are blocked. It’s very frustrating because I can’t find any information about out to unblock an entire website when it’s being blocked. I’d appreciate any help I could get.

The information is out there; it’s just difficult to find because I am a solo, free-time developer.

You can create a /etc/pihole/whitelist.txt with one domain per line and then run again. It doesn’t work perfect yet, but a fix is in the works.

You can also comment out a list if it is blocking too many of the sites you use. I do not control the lists. My script just uses them, but you can pick and choose which ones you want.

I think it was running again that did it for me. I assumed the lists were updated when the system was rebooted so any addition to the whitelist would take place upon every boot. I see now that the whitelist will only update if you run each time there is any change. Thanks a lot!

This is bloody fantastic work Jacob!
Will test soon.. but I only have virtual machine to test on.. but will try when I have the time..
when you add webIF management of white & Blacklist it’ll be just about perfect 🙂

btw.. I tried adding * to the blacklist but that didn’t seem to work.. is wildcards not supported?

Oh.. and for some reason sites like was blocked..

I’ve had to whitelist the following:

which shouldn’t be neccesary..

I’m glad you like it! There are still some kinks, but overall, it’s pretty good.

/etc/pihole/whitelist.txt accepts one domain per line, no wildcards. A regex is used to remove them when /usr/local/bin/ runs.

One problem is that I don’t control what is on the lists; they are all operated by a third-party. So sometimes legitimate sites end up on it, such as Mircrosoft or xkcd. The list that seems to cause the most issues is the mahakala one. If you find too many problems, delete that URL out of the script and run it again. The only other option is to whitelist each one like you have done. Once you add them, will apply them each time it runs, so it’s just a one time change.

Thanks mahakala was giving me lots of issues. Thanks for making this Awesome program though I love it and will be donating very soon.

I’m glad you enjoy it! That is what means the most to me. I’m kind of at an akward stage where the Pi-hole works great and has a decent user base, but there are a few bugs and features that need attention. This means the project is getting big enough that it is difficult to keep up in my free time, so the donations are much appreciated as I would like to do this full time someday.

I have plans for an iOS content blocker, a in-depth Web interface, and more!

Yes, this is true if the script has run at least once since it saves the list to disk. Good catch.


Non-English speaking enthusiast here.

I have followed the instructions. Great Job !

Question :

Where can I find the apache2 configuration equivalent to your lighttpd.conf statement “url.rewrite =” ?

Because I want apache2 to respond with different answers, according to the original request :
– images request: with 25Bytes.gif
– javascript requests: with a stream containing a javascript comment
– htm or html request: with an empty page
– etc


I do not have an apache equivalent file, but I’m sure there is some way to do it. I specifically used lighttpd because is small and fast. Sorry!

Hi J,

Out-Of-The-Box, the DietPi image of PiHole has some apache2 issues:
When observing the /var/log/apache2/error.log, one sees that every request is considered an [error] – File does not exist.
When uncommenting the #CustomLog directive, one sees that every request is logged as a 404 response.

Therefore I have done the following:
1) cd /etc/apache2/mods-enabled
2) ln -s /etc/apache2/mods-available/rewrite.load rewrite.load
3) apachectl graceful
This has activated the apache2 Rewrite Engine

Then I have done the following:
1) cd /etc/apache2/sites-available
2) nano default
3) new lines under :
RewriteEngine On
RewriteBase /
RewriteRule .* myPihole.php
This will send all http request to the php script

Then I have done the following:
1) cd /var/www
2) nano myPihole.php
3) new lines:

4) apachectl graceful
This will always reply with an http response 200,
and with zero content.
Therefore, the requesting browser will be happy.

I hope this helps other as well.


Strange, because it just uses the default index.html, but I will pass this along to the developer of DietPi so he is aware. Thanks!

Remark : The ad domains original requests to be blocked do NOT request any “.html” page. Most of them request a javascript “.js” or even a “cgi-bin”. Therefore, answering with a “index.html” is not the right way to do. Only when manually trying-out the ad domain will one see the “index.html” page. That’s why I have chosen to answer with only the “HTTP headers”, constructed by my “.php” script. And because there are “cgi-bin” requests, I have commented-out the “cgi-bin” directory for the dietpi apache2 host. Please consult your web-server’s logging files to follow and identify the ad domains original requests, and evaluate my modifications. — By the way: there ARE requests that use the “https://” method, and therefore use port 443, where no web-server is actively listening and answering to ! Found this out on dietpi with the SoftEther VPN installation, by inspecting its loggings 😉

Grtz, F.C.

Would you be willing to share the script that responds only with HTTP headers?


– how can we do that ?
– on GitHub ? – where and how ?
– guidance needed.

Grtz, F.C.

Hi, I installed it like you tell but it’s not working. No ads are blocked in any way

This is my status:

* It’s a RPi2 and DietPi is up and running (V90)
* I’m using STATIC PI
* In my network I can ping from and to Pi-hole
* From DIetpi I can ping the internet (i.e.
* Webinterface isn’t found (

I find the solution, I didn’t properly end the installation. After correct installation it all worked just fine !

Is it possible and safe to DMZ the Pi? Advantages are that I can grand access for some relatives to DNS my Pi-hole but I’m afraid of safety-issues

Sorry but i think the newest dietpi update broke everything 🙁 the /var/log/pihole.log is empty, and when i run i get this at the end. kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec … or kill -l [sigspec]

Well that is unfortunate. The DietPi Pi-hole is a fork of my project and it has some quirks in the operating system that you won’t find in the Raspbian automated install. The best course-of-action is to run dietpi-bugreport so the author knows. I also connect with him regularly, so I will mention this to him.

I guess there should be some sort of conditional for that. I recall a discussion that the kill -HUP was graceful and allowed the hosts file to be re-read without disrupting the service. Thanks, I’ll look into it.

After updating from v89 to v92, it stopped working for me. Webinterfaces says 0 DNS Queries Today.

Doing a nslookup;

DNS request timed out.
timeout was 2 seconds.
Server: UnKnown
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** Request to UnKnown timed-out

Any ideas?

There was a different bug with DietPi and Pi-hole that was going to be looked at, so maybe the fix broke something else. Run dietpi-bugreport.

I had to manually create the /home directory. After that I added the user and started service. Now I can use nslookup and I can see queries in web interface again 🙂 Thank you so much.

What is a good place to test add removal since I still get them?

Strange, i’ll look into this further.

You can see the Pi-hole block list by running:
cat /etc/pihole/gravity.list
press ctrl+c to stop print

Then try to access any of those sites

Today it seems to work better. Adds are missing from the site I tested yesterday from PC and iPhone (I checked that DNS server was correct). So for now all seems to work as expected.
Thanks for the great support!

Yes, it should. Are you using a B, B+, or Pi2? Also did you do the DietPi image or the automated install?

Pi2 and I used the image you created and updated it to v92. DietPi dude helped me fix the problem with missing user and get the service running.

Apologies to everyone who has experienced this issue.

I’ve found the cause and a patch has been released with DietPi v93 to resolve it. Simply run dietpi-update.

Leave a Reply