Network-wide Ad Blocking with Pi-hole

Network-wide Ad Blocking with Pi-hole

Ads can sometimes be a bit frustrating, or turn up in places we don’t expect. For example, ads on subscription-based services. Serving ads can also consume a substantial amount of bandwidth on some sites.

There are a variety of ad blocking browser extensions you can install (such as Adblock Plus or uBlock) on your computer to block ads. However, you have to install these on each device you use, and some devices like TVs and games consoles, don’t support extensions.

It would be much more convenient to block ads or any device your home network. That way you’ll reduce the number of ads you see regardless of the device you are using. Thankfully, this is possible by using Pi-hole!

Pi-hole is a DNS based ad blocker, this means it can stop devices on your network from finding the domains which host ads, and a result, prevent you seeing them. You can run Pi-hole on Docker, in a virtual machine or (as the name suggests) on a Raspberry Pi. I opted for the Raspberry Pi option since it was the most convenient for me.

Making sure your Raspberry PI is Updated

The first step is to make sure all the packages on your Raspberry Pi are updated to their latest versions. You can do this by running the following commands in a terminal window.

sudo apt update
sudo apt upgrade

This will fetch any updated packages and then proceed to upgrade your installed packages to the new versions.

Setting a static IP for your Raspberry Pi

Before we move onto setting up Pi-hole we will need to set a static IP for the Raspberry Pi. This will ensure that it’s IP address will not change, making sure devices on the network can always find it.

It is best to do this by adding a reserved address to your router’s DHCP setup. The exact steps to do this can vary between each router, but you can likely find a guide on how to change these settings online.

Installing Pi-hole

You can install Pi-hole by using their one-step automated install script. You can run this by running the following command in a terminal window.

sudo curl -sSL | bash

If you would prefer to review the script before you run it, you can find more detailed installation steps in the alternative install methods documentation.

Selecting a DNS Provider

The first question that the Pi-hole installer will ask you, is to select a DNS provider. If you’re not sure which to select take a look at the DNS Perf website, which should give you an indication of which DNS provider is likely to be fastest for your area.

I selected Cloudflare to be my DNS provider.

Selecting ad block lists

The next question is which third party lists you would like to use to block ads. These are lists of domains which are used to serve ads. I selected the available lists and then proceeded on with the installer. 

Selecting protocols

The next step is to select if you would like Pi-hole to support IPv4 or IPv6 or both. I left mine with both selected, but you can amend these options to suit your network.

Confirming a static IP

This screen will display the current IP address of the Raspberry Pi and the gateway currently in use. The gateway is most likely the IP address of your router (usually similar to

The safest option is to add the current IP address to your router’s DHCP reservation to prevent another device being assigned this IP address.

Select the Yes option if you are happy to proceed, otherwise select No and amend the settings are required.

Next steps

The following installer steps are questions about if you would like the admin web interface, and a web server installing, logging queries, and the level of privacy you would like if queries are logged.

I would recommend installing the admin web interface and the web server to support it. You can amend the other options are you would like.

After those steps, the installer should continue until it is complete, and make the Pi-hole web admin interface available at http://<your-pi-hole-ip>/admin.

Updating DHCP settings

Now that your Pi-hole has been successfully setup, you need to configure other devices on your network to use it for DNS queries. This could be done by changing the network settings on each device, but it saves time to configure DHCP on your router to tell every device to use your Pi-hole for DNS instead.

You can do this by logging into your router, finding the DHCP settings and updating the DNS servers to match your Pi-hole’s IP address. After this is done, when a device connects to your network it will start using the Pi-hole and receive the ad blocking benefits.

You can check a device has received the change by trying to go to http://pi.hole/admin in your web browser. If the Pi-hole admin interface loads, it is working. If it doesn’t, you might need to disconnect and re-connect to the network to receive the new settings.


After following the Pi-hole installer to completion and changing your router’s DHCP settings, all the devices on your network should be receiving the benefit of ad blocking. This should reduce the number of ads you see online and speed up your web browsing experience.