Setup and Configure a Network Wide Adblocker
- Completely Free.
- Network-wide ad block on all devices.
- Simple install – Just one line of code!
Pi-hole is one of the greatest Raspberry Pi projects ever, a network wide ad-blocker that’s easy to install and ensures all devices on you network benefit from it’s fantastic advert blocking magic.
It’s highly recommended to use a Raspberry Pi 3 B+ that is connected to the network via an Ethernet cable. Earlier models of Raspberry Pi will work as well, but for the best performance on a busy network use a Pi 3 B+.
IP Address (IP)
An IP address is a unique (numeral) address that is used to identify a device on the network. Every computer has an IP address and these are used by computers to talk to one another.
Think of it like your postal address or telephone number. If someone wants to contact you they use your unique address, this is the same for a computer and its IP.
Click here for a full detailed description of IP address.
A computer hostname is similar to you wearing a name badge. Computers can be known by their unique IP address, or a nick name (hostname) can be assigned to them. The hostname is the easy to remember name of a computer and like the IP address must be unique on the network.
Click here for a full detailed description of computer hostnames.
DHCP stands for Dynamic Host Configuration Protocol and a DHCP server is the server tasked with giving computers without an IP address their address. It is similar to going to the theater and the box office assigning you a seat. They make a note of your seat row and number so if you’re needed during the performance someone can find you. This is the same job the DHCP server has, it gives computer A an IP address and then gives that address to the DNS server so when other computers want to find computer A they are told where they can find them.
A server usually has a range of IP addresses it is allowed to hand out. E.g. 10.8.110.100 To 10.8.10.199. If you are using a static IP address you’ll want to pick one outside of the range.
Click here for a full detailed description of DHCP.
DNS stands for Domain Name System. A DNS server is like an old fashioned address book. It holds all of the hostnames and IP addresses of computers on the network so when we want to talk to Computer A we can ask the DNS server for their address and they will find it for us. Once found we can then go and contact Computer A.
Click here for a full detailed description of DNS.
SSH stands for secure shell. SSH is an encrypted connection established between two computer programs. On the server side (the computer being connected to) a service is running that listens for another computer trying to contact it via SSH.
Click here for a full detailed description of SSH.
How to Install Pi-hole
Before we start we’re going to ensure the Raspberry Pi is up to date. Run the following commands to grab and install the latest packages:
sudo apt-get update sudo apt-get upgrade -y
Once everything is up to date it’s time to install Pi-hole using the following command. Note, this must be run by a user with sudo privileges (the user pi has sudo privileges):
curl -sSL https://install.pi-hole.net | bash
If you receive the error “curl: (60) SSL certificate problem: certificate is not yet valid”, don’t worry, you’ll just need to use the following command that ignores the reported error. We’ve added “k” to the list of options used during the installation. -k (or –insecure) allows curl to perform insecure SSL connections and transfers:
curl -sSLk https://install.pi-hole.net | bash
Once the installation starts you’ll be prompted with a number of windows. Most can be dismissed straight away with hitting return, but some will require input. The following images will run you through what to input.
A plea to support Pi-hole. If you want to donate anything, follow the URL. From here just hit enter to continue.
This section allows you to select the Upstream DNS Provider. Pi-hole lists a number of popular DNS provides or you can input customs ones by scrolling down. Let’s scroll down and pick CloudFlare for this guide.
This page is asking which protocols we want to use Pi-hole on. It’s best to leave it as default and block ads on both PIv4 and IPv6.
This is just a warning about IP addresses. We’ve sorted this already so can ignore it. Hit enter to continue.
This is a completely fresh install so we don’t have an existing web server. Make sure “On” is selected and hit return to allow the Pi-hole installation to do the hard work for us on installing and configuring the web server.
FTL is what displays the graphs and statistics. We want to monitor everything we can so we’re going to select “Show everything” and hit return. After this the console will flash on and off as it installs, it could take a while depending on the speed of your microSD card, Raspberry Pi and internet. I made a lovely cuppa while it installed.
Now you’ve successfully installed Pi-hole go to the url provided at the end of the installation. For mine it is http://10.8.10.115/admin and you should be greeted by an admin page showing high level information. At the moment mine is empty because we we’re not passing dns requests through it.
On the left hand side click Login and then enter the password from earlier. You’ll then be returned to an updated index page with more graphs and a lot more menus on the left hand side. If you have forgotten the password you can run the following command from the console to reset it and pick your own:
pihole -a -p
Once run you’ll be prompted for a new password and can imediately use the password to login to the admin web page.
I won’t be exploring any of the menus here, they are set to excellent defaults and most easily understandable.
The most likely menu you’ll use is Whitelist. The Whitelist is a list of websites that you want to allow adverts from. Maybe it’s your favourite content provide and you want to support them, or maybe you find certain adverts useful in your browsing. Just pop their URL in the Whitelist box, click add and you’ll be greeted with your whitelisted content.
There really isn’t much to do here, Pi-hole is pretty self regulating. Unfortunately it isn’t currently possible to update Pi-hole from the web interface. Keeping it simple and having it updated only when you decide to, if you login and see a new version is available the update process is a simple one.
SSH into the Raspberry Pi running Pi-hole and run the following:
This command will check for updates and if one is available update Pi-hole and reboot. If you’re feeling really clever you could set a CronTask to run periodically to automatically update Pi-hole.
Router Setup – Wiring it all up
The final step in the process is to direct all of your DNS requests through Pi-hole so it will start filtering what comes back and providing an advert free experience to all devices on your network.
I use pfSense as my router, so the following screenshots are probably of little to no use to you. However, the process is the same no matter what router you use so long as you have the ability to update your DNS servers.
First off, log into your router’s admin section and find the settings for DNS servers. If you’re using pfSense it’s System then General Setup.
Make a note of (in case everything goes wrong) the current DNS servers before deleting the entries.
Add a single DNS server with the IP address of the Raspberry Pi that is running Pi-hole and click save.
Now the DNS settings have been updated all of your devices should be using Pi-hole for their DNS resolution and you shouldn’t see any adverts (or at least very few) on any device that is connected to your network.
If you are having problems connecting to the internet after the change try restarting your device first to see if that fixes the problem. If everything fails, hop back into your router’s admin interface and put the original DNS server IPs back.
If you’re able to access the internet, jump back into Pi-hole’s web admin interface and see all the traffic that’s getting blocked!
Congratulations! You’ve got a working adblocker for every device on your network. It’s time to sit back and enjoy the internet in all it’s advert free glory!
If you want to test your adblocker is working, try a few of the sites below.
https://pi-hole.net/pages-to-test-ad-blocking-performance/ – A list of sites recommended by pi-hole themselves for testing everything is working.
https://ads-blocker.com/testing/ – A simple site for testing if adblock is working. Don’t see an advert? It’s working!
https://thepcspy.com/blockadblock/ – It’s an older site but gives a straight to the point popup telling you if your adblocker is working.