Pi Hole Setup Guide: How to Set Up Pi-Hole Ad Blocker Raspberry Pi and More

Sometimes you just don't want pesky ads. Sure, you can install plugins for ad blocking. But that's relegated to individual web browsers or machines. Instead, you might wish to run an ad blocker at the network level. Enter Pi-Hole ad blocker. This nifty piece of software protects your networked devices from advertisements and internet tracking. Learn all about Pi-Hole, from what it is to how to use it and installation in this complete Pi Hole setup guide!

What is Pi-Hole Ad Blocker?

Pi Hole ad blocker is a piece of software that runs at the network level. As the name suggests, it's intended for use on the Raspberry Pi and other embedded devices. However, virtually any Linux machine should be able to run Pi-Hole. Benefits of running Pi hole include its ability to block ads on gadgets like mobile OSes and smart TVs. Basically, Pi-Hole is a sinkhole server, or a Blackhole DNS. At its most basic, a DNS server is a registry containing public IP addresses and corresponding hostnames. Upon visiting a website, there's a query to the DNS server which looks up the IP address, or location, of the server. A DNS sinkhole is a DNS server which distributes fake results to any systems searching for DNS information. Aside from this functionality, Pi-Hole has the ability to work as a DCHP server. The technology behind Pi Hole is cURL, PHP, dnsmasq, lighttpd, and AdminLTE Dashboard. Pi-Hole replaces your current DNS server and blocks tracking domains as well as ads. 

How does Pi Hole Work?

This private DNS server intercepts ad-serving domain queries and denies access. As such, no advertisements are downloaded. You'll largely see the exact same page, albeit sans ads. The network-wide ad blocking software sits between client devices, like your computers, mobile devices, and smart TVs. Pi-Hole thus blocks requests to ad servers. Since Pi Hole is free, easy to set up, and blocks over 100,000 ad-serving domains, it's a powerful tool. You'll benefit from enhanced network performance. However, many websites do rely on ads for revenue, and often you don't even need to click on an ad for the site to generate revenue. If you're fond of a particular website, I highly encourage you to whitelist it. 

Pi Hole Raspberry Pi Setup

For Pi Hole on the Raspberry Pi, you'll need a few items. First, a Raspberry Pi board. Since Pi Hole is pretty lightweight, even a Raspberry Pi Zero will suffice. You'll need a Raspberry Pi power supply, microSD card for boot medium, and a Linux operating system such as Raspbian. You'll also need an extraction program such as 7Zip, and an extraction program like Etcher. 

What you'll need to set up Pi-Hole:
  • Raspberry Pi board (Raspberry Pi Zero or higher)
  • microSD card
  • Raspberry Pi PSU
  • Raspberry Pi case
  • Linux distro (i.e. Raspbian)
  • Peripherals (keyboard, mouse)
  • Image mounting software (i.e. Etcher)
  • Extraction software (i.e. 7Zip)
Total cost: $10+ USD. The cost of such a Pi-Hole project really varies. You can set up Pi Hole on a Raspberry Pi Zero, old laptop running Linux, or spin it up in a Docker container. As such, you can get started for as low as $10. 

First, download a copy of Raspbian or your Raspberry Pi-compatible Linux OS of choice. You can snag Raspbian over at the official Raspberry Pi Foundation download page. Go ahead and download either a ZIP file or torrent. If you're using the ZIP file, you'll need to extract the compressed image file. The torrent file merely downloads an image file ready to be written to a microSD card.

Once you've downloaded your desired Linux distribution, extract the compressed file if necessary. Then, once you've got your IMG file, use a program such as Etcher to create a bootable disk. When complete, pop that into your Raspberry Pi. 

With a Linux OS loaded and your Raspberry Pi powered on, it's time to install Pi Hole for the Raspberry Pi. Open a command line (CTRL + ALT + T) and run:
wget -O basic-install.sh https://install.pi-hole.net
sudo bash basic-install.sh

After that, you'll see a notification that the PiHole automated installer is running. Press ok an continue. 

Next up, there's a donation screen. Again, click ok and slog on. 

Because Pi Hole is a server, it requires a static IP address. You'll need to configure your network settings (DHCP). Hit ok

Now, pick your interface, Ethernet or Wi-Fi. Highlight eth0 (ethernet) or wlan0 (Wi-Fi), press the spacebar to select the proper option, and press ok

It's time to select your upstream DNS provider. You can pick from Norton, Comodo, DNSWatch, Quad9, FamilyShield, Cloudflare, or a custom DNS server. Pick your preferred option and continue.

Pi-Hole uses third-party lists for ad blocking. By default, it doesn't block any ad-serving domains. Therefore, you'll need to toggle these on. Go ahead and select the block lists you'd like to use by highlighting options and hitting the spacebar. These include StevenBlack's Unified Hosts List, Cameleon, ZeusTracker, Disconnect.me Tracking, Disconnect.me Ads, Hosts-file.net Ads, and MalwareDomains. When finished, press ok, and proceed.

In the next step, you'll need to pick your protocols. IPv4 is pretty standard, but you might want to block ads over IPv6 as well. As per usual, click ok.

Lastly, review your network settings. You'll see your IP address and gateway. The gateway IP address is your router's IP address, and the IP is that of your Raspberry Pi PiHole setup. If all looks good, hit yes

Pi-Hole will display a warning about an IP conflict. This shouldn't occur, but peruse the message and hit ok

You'll be asked if you'd like to install the web admin interface. On is recommended, but you can decline installation of the Pi Hole web interface. The Pi-Hole web UI allows you to remotely manage Pi Hole. I'd suggest installing this. Leave on selected and choose ok

Now, Pi Hole asks if you want to log queries. I'd recommend leaving this on. Pick your preference and click ok

Finally, you'll see a message that installation is complete. At the bottom is the web interface, available at http://pi.hole/hadmin or [your Raspberry Pi Pi-Hole installation IP]/admin. The password is at the bottom too. You can check that Pi Hole is running by entering pihole status in a command prompt. Setting up Pi Hole on Linux should functiona virtually the same except you'll be using a PC or other single-board computer, not a Raspberry Pi. 

Pi Hole Configuration

With Pi Hole properly installed on your Raspberry Pi, it's time to configure Pi-Hole. For whole-home ad blocking with PiHole, you'll need to manually edi your DNS settings. Here, instead of the default DNS, input your PiHole Raspberry Pi's IP address. How you'll perform action varies from router to router, and moreover may not even be possible sans custom firmware like OpenWRT or Tomato. Alternately, you might want to manage the DNS settings of individual devices like PCs or smart TVs. Again, the method of completing this isn't uniform, but you'll simply enter the 

To access the Pi-Hole web UI, navigate to http://[Pi-Hole device IP address]/admin/ and login using the default Pi Hole password. You'll see the PiHole web interface. On the side, you'll see tabs for a dashboard, query log, long term data, whitelist, blacklist, tools, settings, and morel Under settings, you'll find another block lists tab where you can add third-party block lists. It's an incredibly powerful tool capable of much customization. In the web UI, you might wish to turn on or off query logging, or manually whitelist items by editing the whitelist tab on the left-hand sidebar. 

PiHole Raspberry Pi Tutorial: Final Thoughts

Overall, Pi Hole is a nifty piece of software which can help you to simplify ad blocking and domain tracking. You no longer rely on machine-specific ad blocking software. Instead, a Pi-Hole server handles this for you. It's pretty easy to set up, but certain sites might not display properly. Moreover, many websites featuring quality content rely on ads for revenue, so if you like a certain website, consider donating to that site as well as whitelisting them in your Pi Hole backend. 

Are you using Pi Hole? What are your favorite Raspberry Pi projects?

Moe Long

Moe Long is an editor, writer, and tech buff with a particular appreciation for Linux, Raspberry Pis, and retro gaming. When he's not hammering away at his keyboard, he enjoys running, reading, watching cinema, and listening to vinyl. You can read his writings on film and pop culture at CupOfMoe.com and check out his thoughts on movies on the Celluloid Fiends podcast.

Leave your feedback...