Network Wide Ad Blocking with Pi-Hole

Its been a while since a i wrote a blog post so i thought i would share an upgrade i recently made to my home network. My network has plethora of devices connected to it, from Smart TVs and Voice Assistants to ordinary computers and laptops. Where possible i use an internet browser with an ad-blocker installed but sometimes it is just not possible. Recently, however, i stumbled upon Pi-hole and it has changed the game. Pi-hole is a little application that runs on your Raspberry PI and block adverts at the DNS level, it can optionally act as your DHCP server as well. Getting it installed was fairly straight forward, you will need the following:

Note: if you are following this as a tutorial, we are about to format your SD Card. If you need anything off your Pi, now is your time to get it off.

The first thing i needed to do was flash the SD Card from the Rasberry Pi with the latest version of Raspbian Lite. To do this, i used Win32 Disk Imager. The process is pretty simple, all you need to do is select the Raspbian Lite img file you downloaded and choose the drive letter of your SD Card. Finish up by hitting the write button, and wait a couple of minutes for it to complete.


Once the image has been written to the SD Card we need to enable SSH because it is disabled by default on Raspbian. To do this on the headless version of Raspbian we simply create a blank file on the root of the SD card called ssh. This is easily achieved from a PowerShell window, just remember to replace the drive letter with your own.

ni E:\ssh  

At this point your Raspberry Pi is ready to go, plug it into your network and lets grab its IP and start configuring it. There are a number of ways to skin this cat, but i just used my routers "connected devices" interface and a process of elimination. Since there was only 3 wired devices, and two of them fell into a DHCP exclusion range, i knew the IP had to be

Now that we have the IP we can SSH into it, the default SSH credentials are:

  • username: pi
  • password: raspberry

The first thing i needed to do was to set up a static IP. To do this i edited the dhcpcd.conf as follows:

sudo nano /etc/dhcpcd.conf  

The important part is appending the following to the bottom of the file, but once again, dont forget to substitute the IP addresses for your own:

interface eth0  
static ip_address=

static routers=  
static domain_name_servers=  

My dhcpcd.conf file looked like the following once i was done with it.

At this point i rebooted the pi using the reboot command and once again connected to it via SSH, this time using its new static IP address. We now need to install Pi-Hole, which is conveniently done with a one liner.

curl -sSL | bash  

That's pretty much all there is to it. I also used raspi-config to change the host name and password for the box. After about a month of use, i have seen a reduction in the region of 10% with regards to the amount of queries that exit the network.

What software powers your home network? Let me know in the comments.

comments powered by Disqus