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 whitelist or blacklist 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.

Press the ENTER key to continue to the next screen.

Welcome to Pi-Hole Automated installer

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.

PiHole Donation Page Link

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.

Continue to the first set up steps by pressing ENTER.

Raspberry Pi Needs a Static IP Warning

6. You can now choose an upstream DNS provider for PiHole to use.

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 DNS Provider for Pi-Hole

7. Here we can deselect some of the third party lists that will be enabled by default.

These lists are used by Pi-hole to know what domains it should block from loading.

Use the ARROW keys and SPACEBAR to select or deselect a list.

Once you are happy with the selected lists, you can press the ENTER key to continue.

Choose standard Pi-Hole block lists

8. Now we have to select the protocols we want to utilize.

Unless you have a reason, you don’t want to block ads over a particular protocol, leave these options.

Press the ENTER key to continue.

What Protocols to Block Ads On

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

You can see the IP address that it will use on this screen (1.).

If you are happy with the settings, select <Yes>, then press the ENTER key.

Let Raspberry Pi set Static IP address

10. 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.

Warning about potential IP Conflict

11. 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.

Use the ARROW keys, and SPACEBAR to select the option you want.

Once selected, press the ENTER key to continue.

Enable PiHole Admin web interface

12. You will now be prompted if you want to install the Lighttpd web server.

Unless you have a web server installed that you want to use, select the On option.

Once selected, press the ENTER key.

Install Lighttpd as web server

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

We recommend that you leave this switched to “On” as it allows you to keep track of the domain names loaded and have some neat statistics.

Press the ENTER key to continue with the installation.

Allow Pi-Hole to log queries

14. We can configure the level of privacy we want our 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.

Choose DNS Privacy Mode

15. 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.).

PiHole 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. At the moment, this will not show any real stats as we haven’t hooked it up to anything.

For now, let’s just go straight to the Login page. You can find this by clickingLogin” in the sidebar.

Pi-hole dashboard

3. On here, you need to enter the password that you got at the end of the installation of Pi-hole to log in.

Pi-hole login

4. 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.

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 blacklist them.
  • Whitelist – This screen allows you to add certain domain names to Pi-hole’s whitelist. This 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.
  • Blacklist – This screen allows you to add certain domain names into Pi-hole’s blacklist. This means those websites will be blocked by the DNS server.
  • Disable – 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.


  • 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.
  • Query 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 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.

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 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.


  2. Avatar for Robert De Leon
    Robert De Leon on

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

  3. 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.

  4. 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.


  5. 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 *