๐Ÿ”ฅ Thanksgiving Sale! 20% Lifetime discount on ALL memberships and products (CODE: BF2023. LIMIT: first 25 signups) Join Now.
DISCOUNT AUTOMATICALLY APPLIED DURING CHECKOUT

Ultimate Pi-Hole Raspberry Pi Setup: Faster Internet in 15 min

Want to have a better online experience without ads and privacy-invading tracking codes? This Pi-Hole Raspberry Pi setup guide is the one for you.

If you have not heard of Pi-hole, then you are missing something cool. But do not worry, this Pi-hole setup tutorial will help you get rolling in minutes.

In simple terms, Pi-hole is an ad blocker, DNS sinkhole, and optionally a DHCP server.

In this Pi-hole Raspberry Pi setup guide, I will cover everything from Pi-hole introduction to installation and configuration. I will also share some basic maintenance steps and tips.

This will be an updated version of our Pi-hole Setup guide written back in 2020, focus on Raspberry Pi.

Important Note

We debated a lot before writing this guide. Ad blockers are detrimental to content creators (including this website) as typically all ad revenue will be wiped out. Therefore, if you decide to install PiHole on Raspberry Pi for Ad Blocking, please consider supporting us by becoming a member for as low as $1 per month.

What is Pi-hole?

Pi-hole is a network-wide ad blocker. In a typical home environment, this can cut out all ads and trackers on all devices in your home, without having to install an ad blocker on every single device.

How does Pi-hole work?

A DNS server is an internet address registry that helps locate the server using the domain name. When you visit any site, a query is made to the DNS server to locate the IP Address (location) of the server to connect to.

Pi-hole puts itself between your device and an upstream DNS server and blocks out any requests to known ads and tracking servers. Pi-hole can accept DNS queries, but it relies on an upstream server for resolving the queries.

Pihole Basic Dashboard
Pi-Hole Dashboard

Here are some of Pi-hole's awesome features and advantages:

  • Free!!! All you need is a device to run Pi-hole on - Raspberry Pi, Linux Machine, or Docker. No client-side ad block software is required.
  • Over 100,000 ad-serving domains blocked with the default blocklists. There are a number of publicly available blocklists to tailor your blocking.
  • Blocks ads on any device, including those Smart TVs and other devices that do not allow you to make any modifications. The exception is devices with hard-coded DNS explained below.
  • Reduces bandwidth and improves overall network performance. As you can see from the above picture. Over 50% of the ad requests were blocked before they are downloaded.
  • Provides an awesome dashboard to monitor various stats on ad blocking. Pi-hole has a built-in web server that provides an easy-to-use Web UI for administration.

Pi-Hole Alternatives

Recently, AdGuard Home has been gaining popularity as a viable competitor to Pi-hole. In fact, in our AdGuard Home vs Pi-Hole comparison, 67% of our visitors prefer AdGuard Home over Pi-hole.

Which network-wide/DNS adblocker do you prefer?

View Results

Loading ... Loading ...

We have previously covered AdGuard Home installation on Ubuntu, Docker, and configuration tips in separate posts.

We still recommend and use Pi-hole as the differences are marginal and competition is always better. So, let us focus on Pi-hole setup on Raspberry Pi.

Pi-Hole Setup

How to Install Pi-hole?

Pi-hole can be installed on any Linux-compatible system or Raspberry Pi. Pi-hole can also be run as a Docker container, which allows it to be run from devices such as a Network Attached Storage (e.g., Synology NAS). But the most common and recommended way is to run a dedicated Raspberry Pi Pi-hole server.

In this guide, we are going to show you how to install Pi-hole on Raspberry Pi 4. These instructions should also work on any other model of Raspberry Pi, including the previous Model 3 and the cheaper Model Zero W. [Read: Raspberry Pi Models and Cool Projects for Each in 2022]

Docker users check out: How to Run Pi-hole in Docker on Ubuntu, w/ and w/o Reverse Proxy?

Pi-Hole Setup on Raspberry Pi

Setting up Pi-hole on Raspberry Pi is one of the easiest ways to get started on whole-home ad-blocking. On a Raspberry Pi, Pi-hole will function as a self-contained unit. Therefore, no messing with web servers and other setups on a Linux system.

Pi-hole needs ports 53, 80, among others. If you have other services running on the same system, there could be conflicts. While there are ways to resolve conflicts, having a separate Raspberry Pi for this purpose is more efficient and hassle-free. Plus, it is only going to cost you a few dollars in electricity to keep the Pi running.

Getting a Raspberry Pi Pi-hole kit from a reputable distributor (e.g. Vilros or CanaKit) typically saves you a few bucks and is also a convenient one-step purchase. It also ensures compatibility.

Pi-Hole Raspberry Pi Alternative - Linux mini-PC

It can be tough to find a Raspberry Pi these days. If you are not a tinkerer or have no need to add IoT capabilities, a single-board computer may seem like a silly choice for you. It may even be intimidating. An alternative would be to use a mini-PC running Linux, and there are many ways to obtain one.

Ubuntu Mini Pc For Just About $120.
Ubuntu Mini Pc For Just About $120.

ATOPNUC is a good option for just around 120 USD. Just disable booting desktop and turn of sleeping, and you have yourself a lost-cost, low-power, unit.

Now that we have covered alternative options and hardware let us get started with the Raspberry Pi Pi-hole tutorial.

Step 1: What is needed to run a Pi-hole server?

Here is what you will need to follow this Pi-hole Raspberry Pi tutorial successfully.

  1. Raspberry Pi 4 - 2 GB version is the best Raspberry Pi for PiHole. Any version of Raspberry Pi, including older models, should work quite well for Pi-hole purposes. We recommend this Raspberry Pi 4 kit, which comes with a power adapter, case, and heat sinks. A kit is cheaper than getting the items separately.
  2. SD Card - We use SAMSUNG PRO Endurance 64GB MicroSDXC Memory Card.
  3. Raspberry Pi 4 Power Supply (USB-C) - This is already included in the kits listed above. Don't skimp on the power adapter. A bad one can ruin SD cards, among causing other problems.
  4. Ethernet Cable - Although you can use Wi-Fi, we strongly recommend a wired connection for reliability since all your network DNS requests will depend on this.

You will need access to a keyboard and monitor to connect your Raspberry Pi temporarily for setup. You can also use SSH for remote setup, which may add some time to the setup process. [Read: 15 most used SSH commands for Raspberry Pi โ€“ SSH for Raspberry Pi]

What do you run or plan to run Pi-hole on?

View Results

Loading ... Loading ...

Step 2: Install Base OS - RaspiOS Lite

Once you have Raspberry Pi and accessories, move on to setup the base operating system for Pi-hole. There are several that you can use, but we recommend Raspberry Pi OS Lite, which is headless and uses little resources.

Do not worry, although the OS is headless (no GUI desktop environment), you can still manage Pi-hole using its web interface.

Another good option for installing the Pi-hole operating system is DietPi, which is a customized and lightweight OS for Raspberry Pi. During DietPi setup, you will have the option to install Pi-hole among several other apps. In this guide though, we will proceed with Raspberry Pi OS.

Install Raspberry Pi Imager

Head over to Raspberry Pi software page, download, and install the Raspberry Pi Imager.

Complete Pi-Hole Setup Guide - Downloading Raspberry Pi Os Lite
Downloading Raspberry Pi Os

Windows and MacOS installation of the Imager is straight forward. You download the installer and run it as any other package.

On Ubuntu, as of release 20.04 double-clicking no longer opens the .deb installer package with Software Center. You can either right-click on the .deb file, select Open with… and Software Install.

You can also use the command line, which is what I recommend. In this way, you can see what the issue is if it fails to install. For me, it failed because of a dependency issue, but I was able to use the APT package manager to fix the issue.

You do not have to use Raspberry Pi Imager. Balena Etcher is also a popular option. [Read: 6 Best Raspberry Pi Imager Options and My Surprise Top Pick].

Install Raspberry PI Imager on Ubuntu

To install Raspberry Pi Imager on Ubuntu on the command line, use the dpkg command in the terminal app. If you are not logged in as user root, run sudo su and enter your password.

dpkg -i Downloads/imager_1.7.4_amd64.deb

To change into the Downloads/ directory use the cd command. This works on any Linux, Ubuntu, Debian and derivative distros as well. If you encounter an error that software dependencies are not installed, you can fix that using the APT package manager.

apt install -y -f --fix-broken

The -y option is to say "yes" to install the dependencies, -f is to "force" installation, and --fix-broken is to fix packages broken by the error. Then you can rerun dpkg -i to ensure it is fully installed, but the apt command should handle the rest.

Write Raspberry Pi OS Image to SD Card

Once installed, launch Imager. The screen will initially look like this.

Raspberry Pi Imager Start Screen
Raspberry Pi Imager Start Screen

Choose the recommended OS, Raspberry Pi OS (32-bit ARM) Bullseye.

This Screen Shows The Raspberry Pi Imager - Choosing An Operating System Dialog
Raspberry Pi Imager - Choosing An Operating System

Configuring Raspberry Pi Imager Advanced Options
If you do not configure advanced settings, you will need a keyboard and monitor connected to Raspberry Pi to finish the setup. Configuring advanced settings allows you to login to Pi remotely using SSH.

For me, on a Debian computer, the gear icon normally in the bottom right-hand corner is not there (pictured above). On a Windows computer, you can see the advanced settings option as shown below.

Advanced Settings Option In Raspberry Pi Imager On Windows
Advanced Settings Option In Raspberry Pi Imager On Windows

On some Linux distros (and older versions of macOS using newer versions of Raspberry Pi Imager), you might need to use CTRL+Shift+X to make advanced settings appear.

Enable SSH

For Raspberry Pi OS Lite, the advanced options allow you to boot and SSH in as the default user over Wi-Fi. This eliminates the need for a keyboard/mouse, monitor, and ethernet cable (still urged over Wifi).

Raspberry Pi Imager Advanced Options
Raspberry Pi Imager Advanced Options

In the past, you could login to the Raspberry Pi OS using SSH once booted as user "pi" and the password "raspberry", after creating the ssh.txt file. But this was disabled for security reasons.

So, now creating an ssh.txt text file in the /boot directory only works if you have created a default user using Imager Advanced Settings (described below) or another way manually (not described in this guide).

Creating A Default User

You can enable user pi with a unique password in Imager at the same time you enable SSH, but it is NOT RECOMMENDED!

In an update to Raspberry Pi OS Bullseye the Raspberry Pi Foundation recommends you create a new default username and password, especially when enabling SSH on boot. This is what I am going to do.

Raspberry Pi Imager Advanced Options - User
Raspberry Pi Imager Advanced Options For User

Finish Writing the Image

You can also configure Wi-Fi and locale in advanced options but we will skip that part and use ethernet instead.

Next, choose the storage to install on. In this case, the microSD card.

This Dialog Screen Allows Choosing Storage On The Raspberry Pi Imager
Choosing Storage On The Raspberry Pi Imager

Continue to erase all data and write the Raspberry PI OS to SD card. Imager will tell you when it is done.

The Raspberry Pi Imager - Write Successful Screen
Raspberry Pi Imager - Write Successful Screen

Now you can remove the SD card, pop it into the Pi, and boot it.

Be the ONE IN 100,000 that read this, and support us...
  • Feeling generous? Become a member and get ad-free browsing, exclusive content, Discord benefits, and more.
  • Just want to thank us? Buy us a Coffee or a Ko-Fi.
  • May be another day? Shop on Amazon using our links. Your prices won't change but we get a small commission.
  • Don't feel like spending? You can still show your support by sharing this post, linking to it in forums, or even commenting below.

Step 3: Configure Raspberry Pi OS

To start Raspberry Pi OS, insert the SD card into RPi, connect the Ethernet cable, and power up it up. If you did not enable SSH and create a new user, then connect the Pi to a monitor and keyboard, create a new user when prompted, and continue with this Pi-hole tutorial.

Even though you may have enabled Wifi in the Advanced Options previously, we highly recommended using Ethernet as a DNS server is essential for the reliability of your network.
Step 3a: Enable SSH in raspi-config
Note that this method replaces the previous method of enabling SSH access by creating an ssh.txt file.

You can now enable SSH by running:

sudo raspi-config

Choose Interface Options from the menu.

Raspberry Pi Os - Raspi-Config Start Screen
Raspberry Pi Os - Raspi-Config Start Screen

Choose SSH from the next menu screen.

Raspi-Config - Interface Options
Raspi-Config - Interface Options

The next screen will prompt you to confirm with "yes".

Raspi-Config Interface Options - Enabling Ssh
Raspi-Config Interface Options - Enabling Ssh

Now you can use SSH after Raspberry Pi OS boots. [Read: Best SSH clients for Android: 10 free SSH Apps for remote admin]

Step 3b: Raspberry Pi's Network IP

Login to your Wi-Fi router administration page, look through your list of connected clients and note down the IP address of your Raspberry Pi. In my case, it is 192.168.12.223.

While you are there, setup a static IP for your Pi-hole Raspberry Pi (this is required).

Most modern routers rarely change the IP addresses of connected clients. However, when it does happen your Pi-hole instance will not be available and there is a good chance you may not have internet access as well.

The procedure to set static/fixed IP for clients vary by the router. Check this page for some examples of how to do this. The screenshot below shows how to do this on the UniFi controller.

Set Static Ip For Pi-Hole
Set Static Ip For Pi-Hole

Step 3c: Connect to Pi-hole Through SSH

Once you have the Pi-hole's IP address, use an SSH Client such as MobaXterm and connect to your Raspberry Pi through SSH using:

  • IP Address / Host, which in this Pi-hole guide is 192.168.12.223
  • Port 22

Now you can use the new default username and password to login.

ssh w3techie@192.168.12.223

Step 4: Pi-hole Raspberry Pi Installation

Download the script to setup Pi-hole from the command line, locally or remotely through SSH.

There is also a one-line installation script. Though Pi-hole is trustworthy, piping in bash is risky. We recommend the above method.
wget -O basic-install.sh https://install.Pi-hole.net
sudo bash basic-install.sh

This will not require a password on Raspberry Pi unless you have set a root password (by default there is no password for the root user on Raspberry Pi OS).

Without a password a server is considered rootless. This mostly keeps one from logging in remotely as root (security). That is why no password is set for root by default on Raspberry Pi OS. You can, however, decide to enable root login by running the passwd command as root and setting a password.
Introductory Messages

Follow the Pi-hole installer prompts as shown below. Read through the introduction and press Enter to continue.

Pi-Hole Automated Installer Start Screen Is Displayed Here
Pi-Hole Automated Installer Start Screen

Next, you will see a donation screen. If it ends up saving you bandwidth and improving network performance then we strongly recommend donating to Pi-hole.

The Pi-Hole Open-Source Software Donation Screen Is Displayed.
Pi-Hole Open-Source Software - Donation Screen

As stated before, a static/fixed IP is needed for Pi-hole to function properly. Click Continue and proceed.

Pi-Hole Setup - Static Ip Needed Screen Is Displayed
Pi-Hole Automated Installer Screen - Static Ip Needed

Note that here, your router is acting as the DHCP server and giving our IP addresses to your devices (including Pi-hole). Pi-hole has DHCP capabilities as well, which means it can act as your DHCP server and assign IP addresses to your clients.

Check the FAQs later in this guide for Pi-hole vs Router as DHCP server.

Network Interface

Next, you will have to choose which Raspberry Pi network interface to use. Recent models of Raspberry Pi have both wired (ethernet) and Wi-Fi interfaces. As stated before, for reliability, we are going to use ethernet (eth0).

The Raspberry Pi Setup - Choosing An Interface Is Seen Here
Raspberry Pi Setup - Choosing An Interface

Custom/Static IP

While it is not likely this IP will change, it realistically could. A better option would be to set a custom IP. On the next screen, you have a chance to set a static IP, if you have not already configured one.

The Pi-Hole Setup Screen For Static Ip Address Prompts The User Next
Pi-Hole Static Ip Address Setup Screen

Here we can set a custom IP address as shown below (don't forget to include /24 at the end of the IP address).

This Screen Alloows You To Setup An Ipv4 Address
Pi-Hole Configuration Window For Ipv4 Address

Ensure this is an IP address you have configured on your router, not just in the Pi-hole installer.

If you do not set a custom value, you will see this screen next.

This Screenshot Shows The Pi-Hole Automated Installer - Fyi Ip Conflict Screen
Pi-Hole Automated Installer - Fyi Ip Conflict Screen

Upstream DNS Provider

Pi-hole puts itself between your upstream DNS resolving server and clients. An upstream DNS resolving server is usually your ISP (many of them are notorious for hijacking searches etc.) although you may use other custom DNS servers such as Google's public DNS.

We are going to use Cloudflare (1.1.1.1 and 1.0.0.1) for our upstream DNS server because it is privacy-focused, does not store logs for over 24 hours, and does not sell data.

This Window Allows You To Choose A Custom Dns Provider In The Automated Pi-Hole Installer
Pi-Hole Setup - Selecting A Dns Provider

You may refer to this documentation and choose any other DNS provider you please.

Blocklists for Pi Hole

Pi-hole blocks ads using blocklists that contain known ad-serving domain names. Pi-hole has no domains listed in blocklists, to begin with. So you won't be blocking ads until you enable a few third-party blocklists.

This Screen Prompts You To Setup Dns Service For Blocklists
Setup Dns Service For Blocklists

The installer offers you a list of suggested third-party blocklists. We suggest leaving the defaults enabled as shown below and continuing with Pi-hole Raspberry Pi installation. This will get you started with blocking over 100,000 ad/tracking domains, including Google ads.

Pi-Hole Web Interface

Then, you will see an option to enable Pi-hole web interface, which we strongly recommend.

This Screen Asks The User If They Want To Install The Web Server Admin Ui
Installing The Web Server Admin Ui

Pi-hole web interface needs a web server to be available over the web browser. Pi-hole comes with a lightweight web server option using Lighttpd. For Pi-hole on Raspberry Pi, we suggest turning on the Lighttpd web server option, as shown below.

This Screen Prompts The User Again To Confirm Installing Of Web Server Software With Installation Details
Confirm Installing The Web Server Software

Query Logging

Next, you will see an option to enable or disable query logging. Querry logging gives you all the cool statistics about how many requests were blocked, etc.

This is also important to troubleshoot if a legitimate website that you visit is not working properly. You may experience issues while signing up with credit cards, online shopping through affiliate links, etc.

Query logging will increase writes to your SD card and reduce its life. It is recommended to implement ways to extend your SD card's life as prescribed later in this guide. In addition, use an SD card that is rated for high writes like the Samsung Pro Endurance.

To enable logging, choose On and proceed.

Here You Are Asked To Enable Logging By The Pi-Hole Automated Installer
Pi-Hole Automated Installer Screen - Enable Logging

Select privacy mode.

Select The Privacy Mode For Ftl On This Screen
Selecting The Privacy Mode For Ftl

Pi Hole Install Final Step

The final installer screen should show your password to use for the web interface. Note it down. If you forgot to note this down or would like to change the password, see the Pi-hole commands listed later in this guide.

Complete Pi-Hole Setup Server Details Are Shown Here On The Final Setup Screen
Complete Pi-Hole Setup Server Details

What is the default Pi-hole Password?

Pi-hole does not have a default password. It generates a unique password at the end of the installation, which must be noted. If you lost this password, SSH into your Pi-hole server with the username and password for Raspberry Pi OS. Use the command pi-hole -a -p to reset Pi-hole web interface password.

All steps to setup Pi-hole are now done. You should see a Pi-hole installation confirmation message as shown below.

Pi-Hole Setup Guide - Installation Copmlete
Pi-Hole Setup Guide - Installation Complete

Note down your Pi-hole server's IP address, which in my case is 192.168.12.223.

Configuring Devices to Use Pi-hole

There is not a lot of configuring to do on Pi-hole. You can start using it right away. But the devices will have to be configured to use Pi-hole.

In short, you will have to provide your Pi-hole server's IP address in place of the default DNS server IPs in your router or other devices. If you have never changed DNS settings, usually there should be no IP address configured in your settings.

Note: Most device settings give you the option to list at least two DNS name servers. Unless you have two Pi-hole instances running at home, you will provide one DNS IP address and leave the other (rest) blank as shown below. If you specify a second DNS IP that is not a Pi-hole server, ad blocking won't work on some devices. Having two Pi-hole instances is recommended if you are worried about one device failing and cutting off your internet.

Manually Specify Dns In Unifi Controller
Manually Specify Dns In Unifi Controller

Method 1: Configuring The Router for Whole-home Ad Blocking (Recommended)

To block ads on a network level (all network devices use Pi-hole as DNS) manually change or add your Pi-hole DNS server IP on your router as a DNS IP address.

Most routers allow manually setting DNS servers, but some do not make this advanced option available. You can try using custom router firmware to resolve this issue permanently.

Custom Router Firmware

Custom router firmware such as DD-WRT, OpenWRT, and Tomato, open up this option among several others. So if you do not see an option to change DNS name servers, consider switching to one of the supported free alternate router firmware.

The advantage to configuring your router to use Pi-hole for DNS is that there is only one place you will need to update your DNS server IP instead of each and every device. Another reason you might need to block DNS ads at the network level is that some devices do not even offer the option to change DNS settings.

Disadvantages of Using Pi-hole for DNS Only

There are some disadvantages to letting your router handle DHCP while specifying preferred DNS:

  • Per-host tracking will be unavailable and all requests to Pi-hole will appear as if they are coming from your router. My personal opinion is that this is not a big deal for a typical home user.
  • You will not be able to connect to devices with their hostnames as Pi-hole cannot resolve hostnames. Again, not a big deal for a typical home user in my opinion.

Solutions for Per-host Tracking or Resolving Hostnames

If the above two disadvantages are deal breakers for you, then you can partially overcome those by using Pi-hole Hosts file or fully by advertising Pi-hole's IP address via dnsmasq in a router, if supported.

You will have to renew the DHCP leases provided by the router. The easiest way to do this is to restart the devices because resetting them locally on the device itself only updates settings for the single device. Rebooting forces the device to go offline and connect to the router again.

Alternatively, you may let your Pi-hole Server handle DHCP instead of your router, which would eliminate the disadvantages.

Method 2: Configuring your devices (not recommended)

The procedure to manually set DNS servers will depend on the device and the operating system. This process is tedious and not recommended.

In addition, if your device leaves home (eg. mobile phones), you may not be able to connect to your Pi-hole server IP and therefore your internet won't work.

Typically, you will have to open the network connection and find the place to put in DNS server IP manually. Covering this beyond the scope of this guide. Below are some external references for examples, where you can substitute your Pi-hole IP address in place of public DNS IPs.

Pi-hole configuration and customization

To configure Pi-hole, you will have to access the web interface/dashboard.

How do I access Pi-hole admin dashboard?

Pi-hole Admin dashboard or web interface can be accessed using a web browser with the URLs http://IP-ADDRESS/admin/ or http://pi.hole/admin. IP-ADDRESS is the Pi-hole server's local IP address (eg. 192.168.12.223 in this guide). Login using the password provided by the Pi-hole installer.

Configuring Pi-Hole

How to configure Pi-hole? In most cases, there is not much to configure.

One good customization to make is expanding or editing your blocklists. Pi-hole with third-party blocklists blocks over 100,000 domains. These blocklists are trusted and you would rarely have any false positives.

Most Pi-hole users may want to expand on blocklists (eg. for known malware/ransomware hosts). The Pi-hole community is an excellent source of new information, and several users have created and continued to maintain custom expanded blocklists. Firebog Big Blocklist Collection is a notable one.

The Big Blocklist Collection For Pi-Hole
The Big Blocklist Collection For Pi-Hole

Caution: Do not add every blocklist you can find. This can break your internet experience and cause trouble (eg. shopping sites, referral/cashback sites, CNN app, GitHub webpage, etc. may not work). The basic/default lists are a great starting point and already block over 100,000 domains.

Once you have the list finalized, add it to Pi-hole's blocklist by going to Settings -> Blocklists, as shown below. If you went with one of the expanded blocklists, you may want to consider whitelisting some as described later in this Pi-hole guide.

Add Blocklists | Smarthomebeginner
Pi-Hole Add Ad Blocklists

Click Save and Update.

How to Test Pi-hole?

Visit one of the many available Ad block test websites, like this one or this other one. You may have to clear your web browser cache or use incognito mode.

Basic Pi-hole Commands

Almost all admin work to keep your Pi-hole setup and running can be done through the web interface. Within the command line, you can do many of the same tasks as through the dashboard and many more (eg. changing the web UI password). Here are some useful examples.

More Pi-hole commands are documented here.

Pi-hole Help
  • man pi-hole - Latest documentation for Pi-hole
Change Pi-hole Admin Password
  • pi-hole -a -p - Change WebUI password
Status, Realtime log and Statistics
  • pi-hole status - Pi-hole Status
  • pi-hole -t tail log - realtime log
  • pi-hole -c - Pi-hole statistics
Whitelist and Blacklist
  • pi-hole -w -l - List Whitelisted domains
  • pi-hole -w example.com - Add example.com to whitelist
  • pi-hole -w -d example.com - Remove example.com from whitelist
  • pi-hole -b -l - List blacklisted domains
  • pi-hole -b example.com - Add example.com to blacklist
  • pi-hole -b -d example.com - Remove example.com from blacklist
Pi-hole Update
  • pi-hole -up - Update Pi-hole
Query Logging
  • pi-hole -l off - Query logging off
  • pi-hole -l on - Query logging on
Enable Disable Pi-hole
  • pi-hole enable - Enable Pi-hole
  • pi-hole disable - Disable Pi-hole permanently
  • pi-hole disable 10m - Disable Pi-hole for 10 minutes
  • pi-hole disable 60s - Disable Pi-hole for 1 min
Uninstall Pi-hole
  • pi-hole uninstall - Uninstall Pi-hole

Be the ONE IN 100,000 that read this, and support us...
  • Feeling generous? Become a member and get ad-free browsing, exclusive content, Discord benefits, and more.
  • Just want to thank us? Buy us a Coffee or a Ko-Fi.
  • May be another day? Shop on Amazon using our links. Your prices won't change but we get a small commission.
  • Don't feel like spending? You can still show your support by sharing this post, linking to it in forums, or even commenting below.

Pi-hole Tweaks

Here are some Pi-hole tweaks that can make your Pi-hole setup even better.

1. Improving Pi-hole Performance and Life

Move query logging to RAM - protects the SD card

Query logging provides a lot of useful information as shown below. In addition, you get a lot of statistics. However, extensive writing can damage the SD card. For this reason, it is recommended to turn off query logging.

Note that this only affects the Pi-hole log and not the data that is in the long-term database.

But, what if you want to leave it on for all the useful information it provides? A good option, in this case, is to move your logs to RAM instead of SD card. So all your logs on Raspberry Pi OS operating system will be written to RAM instead of SD card, thereby prolonging the life of SD card.

Log2ram

For this, we recommend Log2ram. The GitHub page has all the information for you to get started and customize, which only takes about 5 min or less in total.

USB Boot

You can also choose a USB flash drive as your main drive. Using a USB as your main drive will resolve the issue of writing too many times. USB jump drives are not only more endurant but they are faster than micro SD cards.

You can use the Raspberry Pi Imager to make the Pi boot from USB. SanDisk is a good brand of USB drive to buy.

2. Improving Privacy

Pi-hole ad blocker is great for what it does, blocking ads. But your DNS servers (eg. your ISP, Google, etc.) can and do sniff to find out what websites you are visiting (even the HTTPS sites). This is because DNS name resolutions (eg. google.com refers to this IP) are done as plain texts. In addition, this also poses some level of security risk.

DNS Over HTTPS

The solution here is to send even your DNS lookup through HTTPS protocol (encrypted). Not all DNS providers offer this (because they won't be able to track your activity). Cloudflare does provide DNS over HTTPS.

Setting up DNS over HTTPS with Pi-hole on Raspberry Pi is quite easy. It requires command-line work but it is quite easy if you follow Pi-hole documentation for DNS over HTTPS.

Alternatively, you could use AdGuard Home, which supports DoH out of the box. [Read: Pi-Hole vs AdGuard Home for Ad Blocking โ€“ 12 Key Differences]

How can I test if DNS over HTTPS is working?

Cloudflare has a test page that will provide information on your connection. Visit this page and it will tell you where you are connecting from, which DNS resolvers you are using, and whether the connection is secure or not.

Combine Pi-hole with Unbound

I have Pi-hole and DNS Over HTTPS, can I improve my privacy even more?

Definitely. Take a look at configuring Unbound with Pi-hole. Instead of trusting your upstream DNS (eg. Cloudflare's 1.1.1.1 or 1.0.0.1), Unbound, a recursive DNS resolver that will run locally, will connect to the responsible server directly.

This will avoid the exact path you are visiting from being logged anywhere.

DNSSEC Issue

If you decide to setup Unbound, then make sure to disable caching and DNSSEC validation. Due to some existing DNSSEC bugs in dnsmasq, the developers recommend not using Pi-hole DNSSEC with unbound or Cloudflare.

You can disable DNSSEC using the Pi-hole admin dashboard (Settings -> DNS). Disabling Pi-hole caching requires setting the cache size to 0 in /etc/dnsmasq.d/01-pi-hole.conf, as described here.

Troubleshooting

Hardcoded DNS

If you see ads on some devices and not on some then try rebooting your router first to renew DHCP leases. If you still continue to see ads, then the DNS server IP may be hard coded on the device (eg. Chromecast).

Some allow you to change it and some do not. Look through your device's network or DNS settings to check if you can change your DNS IP to your Pi-hole's IP, or even better your internet gateway's IP (since you have already configured this to run through Pi-hole).

No Internet

This happened when my SD cards failed. If you have no internet, make sure Pi-hole is up and running by trying to SSH into it or opening the Pi-hole admin dashboard. If not, try restarting Raspberry Pi by pulling the power.

Another option is to restore your DNS server IPs on the router/device back to the upstream DNS IP (1.1.1.1 and 1.0.0.1 for Cloudflare or leave them blank to use your ISP's DNS). If the internet works, then the problem is with the Pi-hole setup. You may try to reconfigure using the pi-hole -r command.

FAQs

In addition to the frequently asked questions documented in our other Pi-hole setup guide (be sure to check those out), here are a few more that are specific to running Pi-hole on Raspberry Pi.

Which Raspberry Pi can run Pi-Hole?

PiHole can run on pretty much any Raspberry Pi, including Raspberry Pi Zero. But Raspberry Pi 3 or higher will provide better performance.

Do you need a Raspberry Pi for Pi-Hole?

No. A Raspberry Pi is not a requirement to run Pi-Hole. But it helps to have a dedicated low-power device for Pi-hole and let it run and be available 24/7.

Can I use Raspberry Pi 3 as Pi-Hole?

Of course. In our opinion, if you can find it or have one lying around then Raspberry Pi 3 is a great device to run Pi-hole.

Is there a premium version of Pi-Hole?

No. There is no premium version of Pi-hole. It is fully free and open-source. However, if you find Pi-hole useful, we highly encourage you to donate to the project.

Is Raspberry Pi 4 2gb enough for pi-hole?

Definitely. Raspberry Pi 4 2GB model is a great device for Pi-hole. In fact, this is the Raspberry Pi model used in this Pi-hole tutorial.

Is Pi Zero good enough for Pi-hole?

Yes. Raspberry Pi Zero is capable of running Pi-hole as DNS requests do not need a lot of computing power. You may, however, want to turn off query logging to improve performance.

Does Pi-hole affect speed?

Yes, but in a positive way. Pi-Hole can speed up your internet by saving bandwidth consumed by ads. This increases page load speeds significantly. In addition, it can reduce the number of DNS lookup sent to the upstream DNS server (this is usually only a few milliseconds and barely noticeable).

Pi-hole Tutorial - Closing Thoughts

We tried to cover almost all the basic instructions in this Pi-hole Raspberry Pi setup guide. There are several other advanced tweaks such as the Pi-hole host file, dnsmasq in the router, CGNAT, Pi-hole outside the home network, etc. that were left out of this guide. But the information in this Pi-hole Rpi tutorial is more than enough to get you rolling with whole-home Ad blocking.

Once again, I want to reiterate that by blocking ads, you are essentially hindering content creativity. So if you visit legitimate sites that depend on ad revenue, then please consider donating to those.

I hope you enjoyed this Raspberry Pi Pi-hole setup and configuration guide.

Be the ONE IN 100,000 that read this, and support us...
  • Feeling generous? Become a member and get ad-free browsing, exclusive content, Discord benefits, and more.
  • Just want to thank us? Buy us a Coffee or a Ko-Fi.
  • May be another day? Shop on Amazon using our links. Your prices won't change but we get a small commission.
  • Don't feel like spending? You can still show your support by sharing this post, linking to it in forums, or even commenting below.

w3techie

I am a backend dev. I have done tech support for frontend devs. I have also done container development of every kind. I am an avid Linux user. Ask me anything about Linux or GNU open-source software, and I can tell you. I like to tinker and learn through formal education, and also like to learn things on my own. I have two degrees in web development and system administration. I have also done a lot of network admin, and have been a network technician before too. You know, getting on all fours and barking at Ethernet cords like a dog!

SUBSCRIBE