Anyone use PiHole?

G a f f e r

Well-known Member
Have had a Raspberry Pi Model 1B gathering dust for ages in my room - unfortunately many uses I want (MAME, Media Server etc) would benefit from a newer model but I finally found a use for my lowly 512MB SDRAM, 700MHz CPU, 10/100Mbps ethernet version....

Pi-Hole. This thing is brilliant.

First, you only need to run it headlessly so you don't need the latest raspbian with desktop - just use the Raspbian-Lite version which easily fits on a 4GB SDcard leaving plenty of space to spare.
Once the OS image is installed on the FAT32 card, add an empty file called ssh to the root (no extension) and you can do all set up via FTP from your PC (SSH into the address it's assigned when on using the default username/password)
When it first runs (I had mine powered and plugged into a router port), the latest current raspbian (Sep '19) will commonly fail on "daily apt get-upgrade" so you can reboot to get to the prompt and run "sudo raspi-config" for the first time:
Only need to do a couple of things to the setup - 1) expand_rootfs to allow whole sd card to be used (inside Advanced Options, then first option) and 2) keep username Pi but change the password and allow auto-login (under boot options -> desktop/cli -> console autologin).
DO NOT overclock - I initially OC'd mine to 1000MHz but then got progressive read/write errors until the OS was so unreadable I couldn't even do basic things like log in and then couldn't boot.....wasn't the card, was the OC. Re-set it all up yesterday and left it at 700MHz and it copes fine (DNS serving isn't CPU intensive anyway so OC won't benefit me).
Now reboot and run sudo apt get update and then upgrade and clean (upgrade took 1.5hrs first time I ran it - be patient as subsequent ones will be quicker) then reboot..

When rebooted, ssh into it again and set ip to static (easy to do ... change part of sudo nano /etc/resolv.conf to this (removing # to lines you want):

# Example Static IP Configuration
interface eth0
static ip_address=192.168.1.XXX/24
#static ip6_address=fd61:42d9:cbae:i89e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 1.1.1.1

where XXX is the static ip you choose....change the XXX for whatever number you want and the Pi will always be given this ip address.
That last bit after your router address of 192.168.1 is the backup DNS server for the Pi itself which I set as Cloudfront's (not Google's - see below)

I then rebooted to check it'd worked and ssh'd into it using my chosen ip

Once all done, final thing is to install PiHole with curl -sSL https://install.pi-hole.net | bash and follow the prompts (kept all mine as is apart from again the backup DNS where I chose cloudfront 1.1.1.1 instead of google 8.8.8.8 as CF is MUCH faster to serve requests).

That's it. You can point any devices DNS to 192.168.1.XXX and it'll use Pi-Hole as it's DNS server with high level ad blocking. The web interface allows for standard Whitelisting (for sites you want everything to run) and Blacklisting (additional addresses not caught by the blocklists) but the Blocklists themselves are only recognised as hosts files so won't recognise the normal regex rules in browser adblockers - I'm using the standard pihole ones but haven't yet found a complete Hosts file version of Easylist (currently running 3 based off of it (firebog, someonewhocares and adguardhosts) which pi-hole combines into one, discarding any duplicates).

Despite the fact I've got a very old Raspberry Pi model 1 B with the Lite version of Raspbian on a 4GB sdcard (slow, low and old), FTL serves blocked requests in <1ms and allows good requests in <20ms and stays at <44degC throughout.....so very fast and light weight.


You can therefore use this on "non-standard" devices like TVs and it even works in in-app ads on the iPhone.
With it running I am only using 1 filter on my safari adblocker (adguard) now (using the Adguard General list only in order to block the "on starting" youtube ads (the normal "throughout the video" ads are blocked fairly well on YT with Pi-Hole alone)).

Lots of geeky info in the admin panel too (still can't figure out what the Load indicates though, as it's sometimes red and mostly green regardless of what I'm doing - heavy browsing or not).

Great for a £35 pi (with few quid SDCard) :D.
 

everett_psycho

Distinguished Member
I had this running and it was great. Only issue was I was using a pi 3B+ to run this and an openVPN server and the VPN killed the SD card taking pi hole down with it and killing my entire network until I reset the DNS on the router. I've never got around to setting it up on a new as card.

I didn't find mine blocked much on YouTube but ads in apps and websites we pretty much completely removed from all devices. Definitely worth setting up of you have a pi gathering dust somewhere.
 

Kristian

Well-known Member
I've heard good reports about PiHole and want to try it out. I plan to stick it on my home network but first need to get DHCP running on a different device to the BB router (which doesn't let you change the DNS servers given out.) Other stuff has got in the way somewhat though... :)
 

mjn

Distinguished Member
Yup, got this running on a Unix VM. Does it’s job without fuss. Had a couple of kinks to iron out in the beginning, but all sorted now.
 

GuestOfHonour

Active Member
I’ve had this running for a few months now. A fun little project to set up and tinker with.

You may want to run the following just to save your SD card from all the log writes:

azlux/log2ram

And take a visit here for some good pi-hole related advice - including a useful regex “megathread”:

r/pihole
 

G a f f e r

Well-known Member
...You may want to run the following just to save your SD card from all the log writes:

azlux/log2ram

I'll try that (anything to prolong SD card longevity). If it logs to RAM, does the RAM then fill up (mine is currently stable at 18.2% usage)
 

GuestOfHonour

Active Member
You can set the amount of RAM it reserves for logging; I think it defaults to 40MB but it’s configurable.

I’ve also killed off the daily cron job that writes the log to disk once/day to further reduce the number of times the SD card is written to. So a backup is only created on shutdown/reboot.
 

G a f f e r

Well-known Member
Well it didn't work :(.
Installed Log2RAM as per these instructions and seeing as I had plenty of RAM and GB's of the SDcard free, did as they did and requested 128M of space.
Now when I boot the rPi, it takes >30min to ?dump the files or whatever Log2RAM is doing and then crashes with a kernel panic.
PiHole never gets to load and SSH never starts working either so I can't even login to fix things
Now trying to find how to boot into safe mode and uninstall Log2RAM.....failing that it's a re-install ☹
 

GuestOfHonour

Active Member
That’s a shame. Hope you kept a backup!

The instructions on the github link in my post above (post #6) worked perfectly for me. I left everything at the default value initially - thought it was best just to get it up and running before tinkering.

It’s worth persevering with the installation process (it SHOULD be straightforward). I’ve heard that pi-hole could comfortably wear out an SD card in 2-3 months given the amount of writes made even when just navigating to a single webpage.
 

G a f f e r

Well-known Member
Here’s my boot screen
2C46436D-085D-48E6-8D62-F67D37FA2DCD.jpeg

I think I know the problem. I’ve had PiHole running for some time so on boot, log2ram is writing the WHOLE log file to ram (or trying to) for the first time then gets to 128Mb and crashes with a kernel panic.
IF I installed this initially it wouldn’t have happened because there would be very little to write and it can complete its first task.
Problem now is it performs log2ram first, before even SSH launches or PiHole launches so not only do I have no useful apps running, but I can’t even ssh into it to fix things.

looks like a new build from scratch and yes, this time I’ll clone the card to another 4GB one beforehand 😉

I will try log2ram again but reduce the size to 96M and see if it’s happy - hopefully it’ll all be fine (the biggest thing on starting from scratch is the 1.5hr first apt-upgrade....everything apart from this is easy and quick)


EDIT #1: Just done it. Install order was;
Format SDcard->Raspbian->Update/Upgrade->Log2RAM->PiHole
used your link for log2ram and currently everything working fine :thumbsup: (space set at 96M btw)




EDIT #2: So after leaving it overnight there is an improvement over not having Log2RAM installed.
I have a voltmeter monitoring what the power supply is delivering and previously it would sit at 4.97V or 4.99V. The former indicated that the Pi was doing something, so when it was writing to the SDcard, most of the time I'd see 4.97V. Occasionally when it didn't I'd see 4.99V.
Now, most of the time I'm seeing 4.99V meaning the Pi isn't continuously "doing" something (ie. writing to card). Memory usage doesn't appear to be effected too much but the second thing I've noticed is that previously it would spend a lot of time with the red "high load" icon whreas now it spends a lot of time under normal load:
Screenshot 2019-10-26 at 12.53.22.png

So I also recommend this program if you have a service which writes lots of log files like PiHole does 👍
 
Last edited:

The latest video from AVForums

AVForums Movies Podcast: Which is the best decade for horror movies?
Subscribe to our YouTube channel

Full fat HDMI teeshirts

Support AVForums with Patreon

Top Bottom