Google engineers recently announced a change coming to chromium that will break ad blockers. I personally use uBlock Orgin because it is light, fast and doesn’t allow companies to pay for access. Google already announced that they would be building a native ad blocker into Chrome. That should have been a sign of things to come. Microsoft also announced that Edge would be adopting chromium for its rendering engine. Since I use Firefox, I shouldn’t be concerned. But what if we wanted to block ads before they even reach our network, no matter what device or browser we are using? Enter Pi-Hole.
Pi-Hole is a network-wide ad and tracker blocking program that acts as a DNS for your home network. It intercepts queries for your network and blocks known ad and tracking queries before they are even downloaded. Because of this, it helps web pages to actually load faster. Since it is acting as your DNS for your network, you don’t even have to worry about installing ad blockers on every device, and it also works for things such as smart TVs and other IoT devices. With several ISPs enacting a data cap, pi-hole can help you to reduce your bandwidth.
To setup pi-hole on your network, you need to have an old computer that can act as your server. It doesn’t have to be high-end. This tutorial is for the absolute beginner. It’s made for people who may be afraid to install Linux and are worried about messing anything up. For my build, I had an old desktop not in use so I went in that direction, but you could also use a Raspberry Pi. I would have bought a Raspberry Pi, but I didn’t feel like waiting two days for Amazon to get my order to me. I have also seen people setup a virtual machine on a computer and use the pi-hole that way. If you do that, remember to have your network adapter set in bridge mode. You can also install pi-hole inside a Docker container.
Step One: Get Ubuntu Image Onto Bootable Device
The first thing we need to do is to get the operating system (Ubuntu) onto something that we can boot from. For Ubuntu, a USB stick with 4 GB will work just fine. To complete this step, we need to download Etcher. This program will flash the OS image onto your USB stick. https://www.balena.iEto/etcher
Next, you will need Ubuntu. The supported version of Ubuntu for pi-hole is 16.04 and 16.10. I actually used 18.10 and everything seems to be working just fine. https://www.ubuntu.com/download/desktop
Once you have these downloaded, open up Etcher.
Click “Select Image.” Go to where you downloaded Ubuntu and select it.
Click “Select Drive.” Choose where you want Ubuntu to be flashed to. If you have any external drives, make sure not to choose them. Make sure it’s the USB stick.
Wait for your image to flash onto your USB stick.
After validating, your flash will be complete.
Now, with our newly flashed Ubuntu USB drive, we are ready to move on to the next step… installing Ubuntu.
Step Two: Installing Ubuntu Onto Desktop
Now we are going to use that USB that we just created to install Ubuntu onto an old desktop. First, plug the USB stick into the computer and turn it on. You may have to go into the BIOS and change the boot order. To do this, press F12, computers vary by manufacturer so it could be another Function button, when the computer first comes on. In the BIOS, look for “Boot Order” or “Boot Sequence” and change the order so the computer boots first from the USB stick.
If you boot from the USB stick, you will be at the Welcome screen of Ubuntu. Click Install Ubuntu. We are setting up our installation to act as our DNS, so we need a full installation, but if you wanted to just play around with Ubuntu, you could just click Try Ubuntu.
Keyboard layout: Here you choose your layout for your keyboard.
Updates and other software: Choose Normal Installation. Pi-hole may work with other settings, but I chose Normal and everything works just fine.
Installation type: Here you can choose how to install Ubuntu. Take note of the warning, because your data will be lost if you choose the top option. Ubuntu was able to determine that I had Windows 7 installed on the desktop and asked if I wanted to create a dual boot with Windows and Ubuntu. I actually chose to do this, but I could have easily just formatted everything and start over.
Write the changes to disks? Here, you will see the changes that are about to made to your system. If everything looks good, hit Continue.
Where are you? Click where you are located.
Who are you? Just type in your name, computer name, username and password.
Install: Just sit back and grab a drink as Ubuntu installs on your computer.
Installation Complete: Just click the Restart Now button.
After the reboot, you should be at the the login screen, unless you chose to log in automatically.
Now thatwe have Ubuntu installed onto our computer, let’s move on and perform a few updates and install pi-hole.
Step Three: Installing Pi-Hole On Ubuntu
Okay, now that we have signed into Ubuntu, you will be greeted with a few welcome screens. For 18.10, they consist of setting up your cloud accounts, if you want to send diagnostic information and a software screen. Just exit out of all of those and open the terminal (Ctrl + Alt + T). You can also click the bottom left of the screen to open all apps and search for terminal.
Plug your computer into your router with an ethernet cable.
Then we need to do an update and upgrade of Ubuntu. First, let’s update. In the terminal, type in
sudo apt-get update
Wait for the update to complete. When it does, it’s time to start with the upgrade. Type in:
sudo apt-get upgrade
If you have a problem with the update, try
sudo apt-get update --fix-missing
And if you have a problem with the upgrade, try:
sudo apt-get upgrade --fix-missing
We are missing one final piece in order to install pi-hole, curl. To install curl, in the terminal, type:
sudo apt-get install curl
Now that we have the updates and upgrades complete, and curl installed, it’s time to start with the installation of pi-hole. In the terminal, type in:
curl -sSL https://install.pi-hole.net | bash
Once you do that, you will be bought to the installation of pi-hole screen.
The next few screens will walk you though what pi-hole is. Just press Enter to continue on.
Now, we have to choose which Upstream DNS provider we are going to use with the pi-hole. Use the up and down arrow keys to make you choice. I chose CloudFlare which is located at the bottom.
Here, you can choose which block lists you want to use. When you have made up you mind, hit the Tab key and Enter.
Static IP Address: Take a note of the IP address on this screen. This is the address we are going to use to change the DNS settings in our router.
Select the protocols that you want to support. I just kept both selected.
Screen that warns you about a possible IP conflict.
Yes, you want to install the web admin interface.
Yes, install the web server.
Yes, log queries.
Show everything. It makes things easier.
Time for the installation.
Installation Complete screen. Take a note of the IP and password.
Next, you’re taken back to the terminal.
Before we configure our router, let’s change the password of the pi-hole. Type:
pihole -a -p
and change your password.
Now, let’s head to our router admin page. Routers vary by model, but try typing in 192.168.1.1 in a web browser and log into your router. Look for where you can change your DNS setting. I have a Linksys Velop Mesh WiFi system and it is found under Connectivity -> Local Area Network. You need to change your DNS 1 to the IP of the pi-hole. After you have done that, apply the settings. In this example, my DNS 1 was 0.0.0.0 and I changed it to 192.168.1.157. You can leave the DNS 2 and DNS 3 at their default 0.0.0.0.
Now, in my example, to head to the pi-hole admin page, I would type 192.168.1.157/admin in a web browser.
And here is the dashboard for your pi-hole.
That’s it! If you followed all of these steps correctly, you should now have a network-wide ad and tracker blocker. There are several other things to write about pi-hole, but this has been a long post so I’ll leave that for later. Look for more articles including adding regex, blocklists, setting up your Ubuntu with a static IP and more fun things to do with your pi-hole and Linux.
One last point, at the time of this writing, my pi-hole is currently blocking around 70% of traffic into my network. Wow!