Setup and run Pi-Hole on a Raspberry Pi (2024)

Blocking ads and trackers on your devices typically requires manual labour on each individual device (e.g. installing an ad-blocker on your browser, another on your phone, and another on your tablet). In this guide you'll learn how to install and setup Pi-Hole, a general purpose network-wide ad-blocker, on a Raspberry Pi to block ads on any device connected to your home network.

Last modified

12th January 2022

Guide level

Advanced

Overview

Pi-hole is a general purpose network-wide ad-blocker that protects your network from ads and trackers without requiring any setup on individual devices. It is able to block ads on any network device (e.g. smart appliances), and, unlike browser add-ons, Pi-hole blocks ads on any type of software.

The general setup works as follows (Fig. 1). You install Pi-hole on your server (in this case, we're using a Raspberry Pi) and assign it a static IP address. On your router, you set the DNS primary server to the Pi-hole IP address. When a device connects to your home network, it gets the Pi-hole IP address as its main DNS server from your router. When your device looks up the address for a hostname, it contacts the Pi-hole. If the host is an ad or tracker and present in the list used, the request is instantly blocked. Otherwise, the lookup is performed on some upstream server of your choice (e.g. OpenDNS, Cloudflare, GoogleDNS, your ISP).

Fig. 1: Pi-hole setup overview

Prerequisites

To deploy Pi-hole on your home network, make sure you have all of the following:

  • A Raspberry Pi with at least 512MB of RAM (all Raspberry Pi versions satisfy this requirement) and Raspbian installed.
  • An SD-card with at least 2GB of free space.
  • Internet connection on your Raspberry Pi. Either via Wi-Fi (if available) or via Ethernet cable.
  • Access to your router's administration panel[^1].

[^1]: This is usually available in home networks. Check your router's documentation for instructions and credentials.

Installation

Disclaimer: This guide is based on the official Pi-hole documentation but might not be up to date. This guide is more about giving an understanding of what pi-hole does and how you might want to configure it than a strict step by step guide. For up to date instructions on how to install and any specific issue please refer to the official documentation.

If you're starting with a fresh Raspberry Pi, start by installing Raspbian according to the Raspberry Pi documentation. Then, be sure to install git with the following command:

sudo apt install git

To install Pi-hole, you'll clone its git repository and run the install script.

git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole

cd "Pi-hole/automated install/"

sudo basic-install.sh

The script will guide you through the installation steps and ask for your input to configure basic settings. Any settings you configure during installation can be updated later. At some point, it asks you to select an upstream DNS provider (Fig. 2). This is the server on which lookups of non-blocked hostnames will be performed.

Fig. 2: Select upstream DNS

Then, it will ask you to select an adlist. We suggest you leave the default on (Fig. 3). Later, you'll be able to add more lists, including custom ones, if you wish to.

Fig. 3: Pi-hole adlist selection

Pi-hole is able to block ads on IPv4 and IPv6. Unless you have a specific reason to disable any of those protocols, you can leave both on (Fig. 4).

Fig. 4: Pi-hole protocol selection

It also includes a web interface which you can access to manage your Pi-hole instance. If you're comfortable with command line usage, you can skip the web interface (and server) installation. Otherwise, we suggest you install it (Fig. 5), as well as the corresponding web server (Fig. 6).

Fig. 5: Install web interface

Fig. 6: Install web server

You can choose to log the queries answered by your Pi-hole (Fig. 7), and set a privacy level dictating which kind of logs are stored (Fig. 8). If you're sharing your Pi-hole instance with other people, beware that logs may leak private information (that will be visible to you), so choose your privacy levels accordingly.

Fig. 7: Set query logs

Fig. 8: Set log privacy level

When the installation is finished, you'll get a summary message that includes the IP addresses of your Pi-hole and the randomly generated admin password (Fig. 9). Be sure to save this somewhere (either screenshot or pen & paper) as you'll need it later.

Fig. 9: Pi-hole installation summary

Click OK to conclude the installation. To be sure the installation succeeded, open a web browser and go to http://IP_ADDRESS/admin, where IP_ADDRESS is the IPv4 address of your Pi-hole device (Fig. 9). Note that the http://pihole/admin only works after you setup your device to use the Pi-hole DNS server. Click on log-in and enter your (randomly-generated) password. You should now be in the Pi-hole admin panel (Fig. 10).

Fig. 10: Pi-hole admin panel

Setup

Now that you have Pi-hole installed, the last step is configuring your network to use Pi-hole as its DNS server

The preferred method for doing this is to change your router's DNS server and point it to the Pi-hole IP address, ensuring any client that connects to your network receives the Pi-hole as its DNS server. Typically this requires you to access the router's administration panel. There, you should have a field to set the primary and secondary DNS servers. Set the primary address to the Pi-hole's IP address, and reset any open network connection you may have on your devices. Now, when you connect to your home network, you should get the Pi-hole as the DNS server.

However, some routers do not allow you to change the DNS settings. In this case, you can set the Pi-hole as your DHCP server (and in doing so, you need to disable your router's own DHCP server). Refer to the official Pi-hole documentation to learn how to do so.

Guide

Protect yourself from online tracking

Learn more

AdTech

Found a mistake? An outdated screenshot? Think this could be improved? Check out our Github repository and contribute to help keep these guides up-to-date and useful!

Setup and run Pi-Hole on a Raspberry Pi (2024)

FAQs

Is Raspberry Pi enough for Pi-hole? ›

Despite the name, you are not limited to running Pi-hole on a Raspberry Pi. Any hardware that runs one of the supported operating systems will do!

How to setup Pi-hole in Raspberry Pi? ›

Setup and run Pi-Hole on a Raspberry Pi
  1. 1: Pi-hole setup overview. Prerequisites. ...
  2. 2: Select upstream DNS. Then, it will ask you to select an adlist. ...
  3. 3: Pi-hole adlist selection. ...
  4. 4: Pi-hole protocol selection. ...
  5. 5: Install web interface.
  6. 6: Install web server. ...
  7. 7: Set query logs.
  8. 8: Set log privacy level.
Jan 12, 2022

What is Pi-hole and how does it work? ›

Pi-hole stands between your network and a DNS server. Consider a client device, like your smart toilet, performing a DNS lookup for a domain. The Pi-hole in your network acts like a DNS server; DNS lookups from all client devices, whether that's your smart toilet or your phone, go to the Pi-hole.

What is the minimum Raspberry Pi for Pi-hole? ›

Prerequisites. Pi-hole is a lightweight application that uses very few system resources. It requires 512MB RAM, a microSD card with at least 2GB of free space, and Raspberry Pi OS to make installation on a Raspberry Pi device possible.

Is it bad to run a Raspberry Pi 24 7? ›

Yes, it is completely normal to run a Pi 24/7. Even for years at a time. They use so little power that its not worth turning them off when not in use. I have 4 Pi's running all the time.

Does Pi-hole slow down internet? ›

I can only repeat this: Pi-hole is only involved with DNS resolution. DNS packets are a very tiny amount of all network traffic. Even if it would slow down DNS resolution, it would only slow down the beginning of a connection.

How do you start a Pi-hole? ›

Pi-Hole
  1. Introduction: Pi-Hole. This instructable will teach you how to create a pi-hole from a raspberry pi 3. ...
  2. Step 1: Buy a Raspberry Pi 3 and Add It to Your Network. ...
  3. Step 2: Install an OS on Your Pi. ...
  4. Step 3: Identify the Pi on Your Network. ...
  5. Step 4: Connect and Configure Your Pi. ...
  6. Step 5: Configure Your Router.

What can Pi-hole run on? ›

It is designed for low-power embedded devices with network capability, such as the Raspberry Pi, but can be installed on almost any Linux machine.

Is Pi-hole a good idea? ›

Pi-hole can also block domains that host malware, phishing, or other malicious content, adding an extra layer of security to your network. Another benefit of Pi-hole is that it can reduce your bandwidth usage and data consumption, as it prevents unwanted traffic from reaching your devices.

Does Pi-hole act as a VPN? ›

Via this VPN, you can: use the DNS server and full filtering capabilities of your Pi-hole from everywhere around the globe. access your admin interface remotely. encrypt your Internet traffic.

Is a Pi-hole safe? ›

Enhanced Security: DNS traffic encryption provides an additional layer of security when accessing Pi-hole remotely, reducing the risk of data interception on public or potentially insecure networks.

Is Raspberry Pi powerful enough for AI? ›

Versatility of Raspberry Pi: Throughout our exploration, we witnessed how Raspberry Pi, with its compact size and affordability, emerges as a versatile platform for AI and ML projects. Its adaptability spans various industries and applications.

Is Raspberry Pi powerful enough for server? ›

In fact, server hosting is one of the most popular uses for a Raspberry Pi, and for good reason. They are cheap, power-efficient, and very powerful for their size. However, there are several factors that need to be taken into consideration when choosing a Raspberry Pi to run your server.

Can Raspberry Pi run forever? ›

Provided you have no heat issues (check with /opt/vc/bin/vcgencmd measure_temp ) you can leave your rPi running for all eternity. That's the beauty of the device paired with a well-written OS like raspbian which does not (or hardly) suffer from memory leaks etc. Phil B. Phil B.

Does Raspberry Pi-hole slow down Internet? ›

The only way for Pi-hole to slow down your network is if you've set up something to route all traffic via the Pi-hole server. Pi-hole only handles DNS queries, there is no way for it to slow down the internet connection at all, it doesn't see or handle any traffic other than DNS queries.

Top Articles
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 6379

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.