How to use Pi-hole to block all ads on your local network

pi-hole adblocking via dns

Recently I decided to set up a Pi-hole installation on my local network. Initially I was going to use a Raspberry Pi 3 B+ but the company I work for was replacing all the PCs and I was able to get my hands on one of them.

Pi-hole is a simple tool which can be configured to handle the DNS of all the devices on a network. It can be installed on a linux environment and is also available as a docker image. Basically it will check any DNS queries against various blacklists and block queries that match ad networks or tracking domains. The end result is that you get a browsing experience without advertisements and user tracking. Pi-hole is configurable and you can whitelist domains or even devices on the network if you would like. The admin interface shown in the image of this post shows the dashboard which gives a nice overview of queries that go through Pi-hole.

A Raspberry Pi should be fine, Pi-hole was made for the Raspberry Pi, but simply for reference these are the specs on my box.

Intel Celeron J1900 CPU @ 1.99 GHz (quad core)
8GB RAM
Q1900B-ITX ASRock motherboard
120GB SSD

My box is pretty small and has no fans, the power usage is also fairly low which is great as I will run this box 24/7. The temperature seems to stay around 27 C which is room temperature during the summer where I live.

I decided to use Ubuntu Server 19.04 which is not completely supported at this time and caused me to run into some errors. If you want to have a smooth installation I recommend Ubuntu Server 18.04 LTS. This will install the server version of Ubuntu which does not include the desktop or GUI interface which is simply unneeded overhead for something like this. However if you are new to Ubuntu a GUI can make things easier to maintain, using Ubuntu Desktop 18.04 will also work.

Install Pi-hole

Once you have installed ubuntu run apt update in the terminal.

sudo apt update

After that is done running Pi-hole provides a super simple single line command to auto install everything you need.

curl -sSL https://install.pi-hole.net | bash

For most of the prompts during install you can simply select the default and click ok. It will also ask for an Upstream DNS provider, if you have a preference simply pick the one you like, personally I prefer to use Cloudflare for my DNS.

Make sure to make a note of the IP. You can check the IP of the server by typing ifconfig in your terminal. To configure the password type the following.

pihole -a -p

This will prompt for a password which will be used for your web interface. You can now open your browser and go to {yourip}/admin and you should see something like this.

Updating Device DNS Settings

The last step is to configure your router and/or computers to use the local ip of the pi-hole box for DNS queries. On mac you can change this by going to System Preferences->Network clicking on Advanced and then under the DNS tab remove anything there and add the IPv4 and IPv6 addresses of the pi-hole. A quick Google search should return easy to follow guides for most devices and operating systems. You may need to restart devices after updating these settings.

That’s it, you can now try turning off any ad blockers you use to see that pi-hole is working.

Author: Markus Tenghamn

I have been building websites and apps since I was 13. At 18 I was running my own web hosting company. I love writing, it is one of my favorite hobbies which lets me share things I find interesting with others. Don't forget to follow me on Twitter.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.