Raspberry Pi Pi-Hole: A Network Wide Ad-blocker

In this Raspberry tutorial, we will be setting up a network-wide ad blocker called Pi-hole. Pi-hole works by acting as your DNS server and blocking domain names that are often affiliated with advertising.

Raspberry Pi Pi-hole

What Pi-hole does is act as your DNS server. Your computers and routers will connect to it for DNS requests.

These DNS requests will then be filtered by the Raspberry Pi.

Any DNS requests that match a known ad host will be rejected, meaning the connection will never meet your computer. Therefore the ad will never be loaded by the devices.

Network-wide adblocking is a useful tool for stopping ads from appearing on devices that don’t have any easy to use adblock tool.

It’s also a handy way to improve your network performance and bandwidth usage as the number of files downloaded during normal web browsing will be reduced.

It also has the added side effect of potentially improving the security and the privacy of your network, as some sites use relatively dodgy ad providers.

You can install the Pi-hole on other operating systems other than Raspbian. They have support for Ubuntu, Debian, Fedora, and CentOS 7 (Non-ARM).

If you decide to use the network-wide ad blocker, please consider subscribing to our ad-free service to help support the site and allow us to continually grow.

Equipment List

Below are all the pieces of equipment that I made use of for this Raspberry Pi Pi-hole tutorial.



Installing Pi-Hole on to the Raspberry Pi

1. To set up our network-wide adblocker, we are going to utilize a piece of software called Pi-hole.

Pi-Hole is the software package that will be handling everything for us. It sets up and configures a DNS server that can be configured to whitelist and block individual domain names.

It also provides a fancy web frontend to the whole system. This frontend allows you to see the statistics in real-time and make changes to the Pi-hole configuration. This includes the ability to block list specific URLs.

The Pi-hole install script automatically installs the Lighttpd web server. You don’t have to worry about setting your own up beforehand.

We can run this single command to download and run the Pi-hole install script.

curl -sSL https://install.pi-hole.net | sudo bash

While we know Pi-hole is safe, if you want to check the script that we will be running yourself, go to the Pi-hole install domain in your web browser.

2. Once you have run the command, it will download and run the script that begins setting up your device for Pi-hole.

A few of the tasks it does are verifying the amount of available free disk space, updating the package list, and several other things.

PiHole Install Script Starting

3. The first screen informs you that you are about to transform your Raspberry Pi into a network-wide adblocker.

Before you continue, please note that you can navigate this interface using the ARROW keys. To select an option you will need to press the ENTER key.

Press the ENTER key to continue to the next screen.

Raspberry Pi, Pi-Hole Welcome Screen

4. You will be informed that you can donate to help with the development of Pi-Hole.

If you would like to help the team out, follow the link shown within this step.

Press the ENTER key to continue with the setup process.

Open Source donation message

5. Next, is a screen informing you that you must have a static IP address.

The installation script will handle this process for you. However, it is best to set the IP through your router using DHCP reservation as well.

To continue with the setup of Pi-Hole on your Raspberry Pi, select the “Continue” option then press the ENTER key.

Static IP address required for Pi-Hole to Operate

6. You will now be asked if the current network settings are fine to use for the static IP address setup.

At the top of the screen, you will see the IP address and gateway (1.) that your Raspberry Pi is currently using.

If you are happy with the settings, select the “Yes” option (2.) and then press the ENTER key to continue.

Attempt to automatically set a static IP

7. You will now be warned that there is a chance the router will assign this IP address to another device.

However, most routers will try and avoid this from becoming a problem. To completely solve this problem, you will need to use DHCP reservation as well.

Press the ENTER key to continue.

Static IP address required for Pi-Hole to Operate

8. You can now choose an upstream DNS provider for Pi-Hole to use on your Raspberry Pi.

Whenever Pi-hole has a request that isn’t cached or blocked, it will contact the upstream provider for the IP address.

For our tutorial, we will be using Cloudflare as our DNS provider.

You can select your option by using the ARROW keys. Once chosen, press the ENTER key.

Select Upstream DNS provider for Pi-Hole on the Raspberry Pi

9. Here you will be asked if you want to add the recommended blocklist during the installation process.

A block list is what Pi-Hole uses to know what domain names should be prevented from loading.

If you are happy to use the default Pi-Hole block list on your Raspberry Pi, select “<Yes>” and then press the ENTER key.

Enable default blocklists

10. You will now be asked if you want to set up the Pi-hole web admin interface on your Raspberry Pi.

We recommend installing the web interface as it gives you access to an easy way to configure Pi-hole and check on statistics.

To proceed with the installation of the admin web interface, select the “< Yes >” option and press ENTER to continue.

Install the Pi-Hole Web Admin Interface to the Raspberry Pi

11. You will now be prompted if you want to install the Lighttpd web server to run Pi-Hole’s web interface.

Unless you have a web server installed that you want to use and know how to configure it, select the “< Yes >“option.

Once selected, press the ENTER key.

Additional software required to run admin software

12. Now you will be asked if you want to log the DNS queries.

We recommend that you select the “Yes” option as it allows you to keep track of the domain names loaded and have some neat statistics. However, if you prefer your privacy select the “< No >” option instead.

Press the ENTER key to continue with the installation.

Enable DNS query logging

13. We can configure the level of privacy we want our Raspberry Pi’s Pi-hole DNS server to have.

For our guide, we will be sticking with “0 Show everything“. This setting allows us to retain the most statistics.

Use the ARROW keys, and SPACEBAR to select your privacy setting. Once set, press the ENTER key.

Set privacy mode for Pi-Hole FTL service

14. Installation of the Pi-hole server on your Raspberry Pi has now completed.

This screen will tell you how you can gain access to the Pi-hole web interface (1.).

As well as show you the password that you need to use to log in to the admin account (2.).

Installation Complete with Login Details

A Quick Look into the Pi-hole Web Interface

1. To get to the Raspberry Pi Pi-hole web interface, all we need to do is go to the following web address in your favorite web browser.

Make sure you swap out with the IP address that was displayed in the last step of the previous section.

2. You will be greeted with the following screen asking you to login to the Pi-hole web admin interface.

To login to this interface you will need to enter the password (1.) you got at the end of the last section.

With the password typed in, you can now login by clicking the “Log in” button (2.).

Login to Pi-Hole Web Admin Interface

3. You will now be presented with the admin dashboard.

This dashboard is just like the normal one with a couple more graphs and access to all of the configuration pages.

Below we will go through some of the pages that are available within the Pi-hole interface.

Raspberry Pi Pi-Hole Admin Dashboard
  • Query Log – The query log shows all the most recent queries that have been made to the DNS server. It is an easy way to find a recent address that may have been loaded and blocklist them.
  • Groups – Pi-Hole allows you to separate clients into different groups. This feature is useful if you only want certain clients to have ads or domain names blocked from loading.
  • Clients – The clients interface is where you can add a particular client to a specific group.
  • Domains – This screen allows you to add certain domain names to Pi-hole’s whitelist or blacklist. They can even be assigned to particular groups.

    A whitelist means those websites will no longer be blocked by the DNS server. However, if that domain is blocked by a wildcard, then it will continue to be blocked.

    Being on the blacklist means that Pi-Hole will block that particular DNS request.
  • Adlists – Pi-Hole on the Raspberry Pi allows you to add third-party blocklists through its Adlists interface. Use this interface to add or remote additional blocklists from Pi-Hole.

    Like the domain interface, the adlists interface allows you to apply a blocklist to a specified group.
  • Disable Blocking – These options allow you to temporarily or permanently disable the blocking functionality of Pi-hole. It will continue to function as a normal DNS server while disabled but will no longer block DNS requests.
  • Local DNS – Another feature of Pi-Hole is that it lets you specify your own DNS records. This is useful if you want a particular domain name to be routed elsewhere. It is also useful if you have local domain names.


  • Update Lists -This tool allows you to trigger an update of the ad blocking lists. It is useful for ensuring you are running the latest versions of the ad block lists.
  • Search Adlists – This tool allows you to find out if a certain URL is being included in the ad blocking lists, it is useful for checking why a certain URL might be getting blocked.
  • Tail pihole.log – This tool shows the last lines of the pihole.log file and continually updates live, this is useful for checking to see what Pi-hole is doing to requests.
  • Settings – This section contains some configurable settings, this allows you to change the way your DNS works, what upstream DNS providers you want to use among several other options. You can even enable DNSSEC in the options.

For the average user, you will not need to change these options unless you made a mistake in the initial installation.

Connecting your Network to use the Raspberry Pi Pi-hole

There are two different methods for setting up the network-wide ad-blocker on your network.

The first of these two options is the easiest and will extend the Pi-hole coverage to all your devices.

This option is to change your router’s DNS settings to point towards the Raspberry Pi. We recommend this for setting up the network-wide adblocker.

The second is to set the DNS setting for each of your devices. This method is more challenging to set up and something you must do every time you add a new device to your network.

However, it can be useful if you only want specific devices running through the adblocker.

Setting Routers DNS Settings

Changing the DNS settings is different for every router, but we will go through the steps we used for our router. First, we need to go to the router’s admin page. Most routers reside on the local IP address.

If you are asked for a username and password but are unsure of what it is, then try using admin for the username and admin for the password.

Once you are logged in, look for anything mentioning the DNS server or DHCP server.

For my TD-W8960N router, these resided under “Advanced Setup” then under “DNS” then “DNS Server“.

Within this screen, set the primary DNS server to the IP address of your Raspberry Pi, for example, mine is

Make sure it is the only DNS server that is set, as it handles all upstream DNS services itself, and adding alternatives could break the functionality of the adblocker.

PiHole DNS Configuration

Windows DNS Settings

Below are the steps to changing the DNS settings on your Windows device to point to your Pi-hole.

DNS settings are specified in the TCP/IP Properties window for the selected network connection.

1. Go to the Control Panel

2. Within the control panel, click the Network and Internet option.

Windows go to Network and Internet

3. Now click Network and Sharing Center.

Windows Network and Sharing Center

4. Within this center, click the Change adapter settings option in the sidebar.

Windows Change Adapter Settings Option

5. In this network page, double-click the network connection that you want to configure.

Select Network Connection

6. Within the connection properties, you will need to find the connection type.

Make sure you select IPv4 or IPv6, depending on what you are using (1.).

Once you have one selected, click the Properties button (2.).

Windows Select connection Type Properties

7. Within the properties page, there are a couple of things you will need to do.

The first is you need to click the “Use the following DNS server Address” radio button (1.).

You will need to enter the IP address of your Pi-hole device in the Preferred DNS server textbox (2.).

With everything set, click the “OK” button.

Windows Change DNS settings to pi-hole

8. Repeat the procedure for additional network connections you want to change.

Linux DNS Settings

In most modern Linux distributions, DNS settings are configured through Network Manager.

1. Click System > Preferences > Network Connections

2. Select the connection for which you want to configure

3. Click Edit

4. Select the IPv4 Settings or IPv6 Settings tab

5. If the selected method is Automatic (DHCP), open the drop-down and select Automatic (DHCP) addresses only instead. If the method is set to something else, do not change it.

6. In the DNS servers field, enter your Pi’s IP address

7. Click Apply to save the change

8. Repeat the procedure for additional network connections you want to change.

9. If your distribution doesn’t use Network Manager, your DNS settings are specified in /etc/resolv.conf.

Mac OS X DNS Settings

1. Click Apple > System Preferences > Network

2. Highlight the connection for which you want to configure DNS

3. Click Advanced

4. Select the DNS tab

5. Click + to replace any listed addresses with, or add, your Pi’s IP addresses at the top of the list:

6. Click Apply > OK

iPhone DNS Settings

1. From the iPhone’s home screen, tap Settings.

2. Tap Wi-Fi. The available wireless networks in range of your iPhone should appear.

3. Find your wireless network in the list and then tap the arrow.

4. Tap the DNS field.

5. Delete the current DNS servers, and enter your Raspberry Pi’s IP Address.


If you love your privacy, then other Pi projects might take your fancy. Something like the VPN access point is great if you want to add an option for people to hook into a VPN by simply joining a Wi-Fi access point.

You also may want to try improving the privacy of Pi-Hole on your Raspberry Pi by setting up Unbound.

I hope this Raspberry Pi tutorial on installing Pi-Hole has helped you be successful in your set up on your Pi.

If you have any thoughts, feedback, or anything else, then be sure to leave a comment below.


  1. Avatar for Peter Gräbner
    Peter Gräbner on

    By the way, I found some specific German blacklists and I went with the strategy to block much and then add needed domains to my whitelist, which is really done quick with the pihole gui or the command line.
    During working time PiHole blocks about 25% of the web traffic, at night around 40%. Amazing!!! And most of them are trackers and advertising nets.

  2. Avatar for Dean West
    Dean West on

    What are the memory requirements for the raspberry pi 4B to run this? This will be my first pi purchase and I don’t won’t go over buy (money is tight lately) but also really don’t want to underbuy. Also as a noob, could I use the same pi to be an AirPrint server as well as a pi-hole? Anyone have a memory suggestion to run both on same pi (if it’s even possible). Thx in advance

    1. Avatar for Emmet
      Emmet on

      Hi Dean,

      Pi-hole is actually a pretty lightweight bundle of software so it doesn’t consume that much RAM or processing power. As long as the Raspberry Pi has at least 512mb of RAM then you are good to go.

      So in the case of the Raspberry Pi 4B you can very easily go with the 2GB version and have plenty of room to go for some additional.

      On the case of using the AirPrint server software you should be completely fine to run both Pi-Hole and that. They both operate on different ports so their should be no conflict. It also doesn’t consume a huge amount of RAM and a 2GB Raspberry Pi 4B should be more then enough to run both sets of software.

      Let me know if this answers all of your questions.


  3. Avatar for Robert De Leon
    Robert De Leon on

    I just installed this today. Its was easy peasy as some kids say. Thanks!!

  4. Avatar for alex
    alex on

    It’s a nice project, tried this with dietpi + pi-hole, the problem is it won’t block youtube ads on iphone’s app and like 1/3 is going to block it when using browser. I cannot say I care that much about other ads.

  5. Avatar for Fritz
    Fritz on

    Hi Gus,

    this is a very nice summary and really helpful. I’m a total newcomer in this area. I just followed your instructions to set up a pi-hole with my new Raspberry pi 4 B and all worked well. My intention is then to connect with my router.

    May I ask you a dumb question: how do you suggest connecting the Raspberry to the router (in my case an Asus RT-A68U). Is an ethernet connection preferable over a wif-fi?

    Thanks in advance,


    1. Avatar for Emmet
      Emmet on

      Hi Fritz,

      An ethernet connection is preferable as it is typically the fastest and most reliable connection.

      While you can use Wi-Fi if you want, having the Raspberry Pi lose connection while working as your DNS server is not something you want.


  6. Avatar for Jack Rubin
    Jack Rubin on

    Thanks – very helpful and clearly presented.

Leave a Reply

Your email address will not be published. Required fields are marked *