Blog

How to block ads on all of your devices with Pi-hole on a Raspberry Pi

Affiliate links on Android Authority may earn us a commission. Learn more.

It’s no secret that online advertisements can sometimes disrupt your web browsing experience. Even on mobile, it’s impossible to escape banner ads, pop-ups, and other unwelcome distractions. Phone and TV manufacturers have also started sneaking advertisements into Android skins and interfaces. Thankfully, there’s an easy way to block ads on your entire Wi-Fi or home network, with hardware as inexpensive as a Raspberry Pi Zero (~$10) and a piece of free software known as Pi-hole. Follow along to learn how. 4-Head Combination Drilling Machine For Aluminum Profile

How to block ads on all of your devices with Pi-hole on a Raspberry Pi

To block ads on your entire home network, all you need is a DNS filter like Pi-hole running on a low-power computer, like a Raspberry Pi. Then, simply change the DNS settings on your router to send future queries to the Pi-hole computer instead of the default setting.

You’re probably already familiar with browser-based extensions that allow you to block ads from websites. However, that’s not always a viable strategy — most Android web browsers, including Chrome, don’t support extensions. The same applies to smart televisions, game consoles, and other non-browser apps. Luckily, you can block ads across your entire network using a DNS-level filter or sinkhole.

DNS stands for Domain Name System. Its job is to convert human-readable domain names (like www.google.com) to an IP address that computers can recognize. By default, your router forwards all DNS queries to your internet provider’s servers.

However, we can also change some settings and route all DNS requests to a different destination — such as the Pi-hole ad-blocking filter we’ll install in this guide. Then, whenever a device on your network tries to contact an advertising-related domain, our custom DNS server will block it. Other non-advertising domains, meanwhile, will continue to be passed through to an upstream DNS server like Google or Cloudflare.

The advantages of this approach are clear: you don’t have to install ad-blocking software on each and every device in your household. Moreover, it only needs to be set up once. Filtering DNS is also extremely resource-efficient since the process happens on a separate, dedicated device. If all of that sounds good to you, here’s how to install Pi-hole on a Raspberry Pi to block ads across your entire network.

For this guide, you’ll need a computer that you can leave running throughout the day. Since DNS queries are extremely lightweight, the Raspberry Pi family is the perfect choice for this purpose. These devices consume very little power and you can even get away with the lowest-end Raspberry Pi Zero W (~$10) or an older full-sized Pi 3 (~$25-35). You can also repurpose an old laptop or desktop for this purpose — just ensure that you don’t pick powerful, power-hungry parts. Here’s everything you’ll need:

Once you have the hardware ready, it’s time to install an operating system to the microSD card. Start by visiting this link on a desktop computer or laptop and downloading the Raspberry Pi Imager tool. Then, insert the microSD card into your computer.

Next, install and open the tool. Select Raspberry Pi OS (Raspbian) as your operating system, and the microSD card from the list of drives.

Press Ctrl + Shift + X simultaneously to bring up the advanced settings menu (pictured below). Click on Enable SSH and enter a password. If you’d like to use a wireless connection on the Pi, you should also enter your Wi-Fi credentials here.

Close the advanced settings menu and hit the Write button. Acknowledge the warning and proceed. At this point, the tool will automatically download a copy of the Raspberry Pi OS and write it to your microSD card.

Once complete, pull the microSD card from the computer and insert it into the Pi. Power up the board and wait for it to boot — it may take a few minutes. If you didn’t enter your Wi-Fi details earlier, don’t forget to connect the Pi to your router via an Ethernet cable.

With the Raspberry Pi up and running, all we need to do now is install Pi-hole and configure your router to redirect DNS queries to it instead. Before that, though, we must figure out the Pi’s IP address on our local network. An easy way to do this is with a network scanning app like Fing. In my case, the IP address was 192.168.0.107 (pictured below), but it might look completely different for you.

With that, we now have enough information to remotely connect to the Raspberry Pi. Remember the SSH setting we turned on in the previous section? That will allow us to execute commands on the Pi from a different computer or smartphone. For this tutorial, we’ll use PuTTY on Windows, but the general steps are the same even if you use a different SSH client like Termius on Android or iOS.

How to install Pi-hole on a Raspberry Pi:

Open your preferred SSH client, enter your Raspberry Pi’s IP address from the previous step, and click Connect or Open.

Accept the security prompt, if one appears.

When prompted to login, enter pi for the username. Finally, use the password you set in the previous section.

We can now install Pi-hole. Simply copy the following command and paste it into the SSH client. Then, press enter to execute it.

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

Eventually, you’ll be presented with a one-time setup process for Pi-hole. Follow the instructions on-screen — you can use the default settings throughout.

At the end, you’ll be greeted with an installation summary screen. Here, make a note of your IPv4 address — we’ll configure our router to use it in the next section.

If you’d like to manage your Pi-hole later, don’t forget to also write down the web interface address and password.

You may now close the SSH session.

At this point, you should have a successful Pi-hole installation from the previous sections. In this final section, we’ll configure our router to send all future DNS queries to the Pi-hole. This can be a bit tricky, since the exact steps vary depending on your router’s brand and model. However, most major brands have support pages detailing how to configure DNS settings, like this one for TP-Link or this page from NETGEAR.

As you can see in the screenshot above, simply change your router’s DNS server entries to our Pi’s IP address from earlier. This will ensure that all queries are sent to our Pi-hole, which will filter advertising-related domains for us.

While we’re at it, you should also set a static IP for your Raspberry Pi. This will ensure that the router doesn’t assign your Pi’s current IP address to a different device. If that happens, your DNS queries will fail to resolve and it will seem as if you have no internet connection. Once again, consult your router manufacturer’s support pages for step-by-step instructions, like this page from NETGEAR.

If you cannot access your router’s administrative panel for some reason, you can also change DNS settings on each device manually. Once again, this can vary depending on your device’s operating system and version. On Windows 11, you’ll find it under Settings > Network & Internet > Wi-Fi > Manage known networks > Your home network. Change both DNS entries to your Pi’s IP address, as shown in the screenshot below.

To change your Android device’s default DNS servers, head into Settings > Network & Internet > Wi-Fi. Then, long-press the network’s name, tap Modify network, and Show advanced options. Finally, change IP settings to Static and enter the IP address from earlier.

Pi-hole references a database of known domains to block advertising-related websites at the DNS level. On the other hand, ad-blocking extensions manually filter out advertising-related code after you load a webpage. Both approaches work well, but extensions might do a better job in certain complex instances, like YouTube ads.

A Pi-hole is a free piece of software that can block ads across your entire Wi-Fi network after a one-time setup.

No, you can install Pi-hole on just about any computer. The Raspberry Pi is one of the least power-consuming options out there.

How to block ads on all of your devices with Pi-hole on a Raspberry Pi

Single Head Cutting Saw No, a Pi-hole has nothing to do with a VPN and you don’t need to install any apps. Simply change your DNS settings, either on your router or on individual devices.