Install and use Pi-hole to block ads on your network

  • Pi-hole acts as a centralized DNS server and blocks advertising and tracking domains for all devices on the network.
  • The typical installation is done on a Raspberry Pi with Raspberry Pi OS, enabling SSH access and assigning a static IP address.
  • It is key to configure the router to use Pi-hole as the primary DNS, manage the block lists, and prevent secondary DNS servers from bypassing it.
  • The web panel allows you to monitor the network, update lists, and create backups with Teleporter to protect your configuration.

pi-hole

If you are Tired of seeing ads on all your devices? Every time you connect to your home WiFi, you've probably heard about Pi-holeThis small project, originally designed for a Raspberry Pi, has become a very popular solution for blocking ads and trackers at the network level, without having to install blockers on each computer, mobile phone, or tablet.

Although it may sound technical, setting up and using Pi-hole is a process perfectly manageable even if you're a beginnerThere are people who literally start from scratch, with doubts about what to buy, how to connect it to their router, or what steps to follow without messing things up.

What is Pi-hole and how does it work on your network?

Pi-hole is basically a DNS server that filters ads and trackers for your entire local network. Instead of each device resolving the addresses of the websites it accesses on its own, all those requests first go through Pi-hole, which checks if the domain is on blocklists and, if it is, sends it to an unresponsive address, thus preventing the ad from being downloaded.

Pi-hole is primarily designed to be installed in a Raspberry Pi (such as a Raspberry Pi 3 B+ or higher)However, it can also be installed on other devices, such as a NAS or even a virtual machine. The important thing is that it has a static IP address on your network and is reliably accessible, as it will act as the central DNS resolution point.

When Pi-hole detects that a request is going to an advertising or tracking domain, it redirects that query to a Non-existent IP address or local IP address where nothing is being loadedThe practical result is that banners, video ads, and many tracking scripts stop appearing. Furthermore, pages load faster because time and bandwidth aren't wasted on content that doesn't provide any value.

It's important to understand that Pi-hole... It's not perfect and it doesn't block 100% of ads. Especially some that are more intricately integrated into certain platforms. But the reduction in advertising and tracking is usually very noticeable. Many users report that after installing it, browsing becomes much cleaner and smoother on all their devices, without needing to adjust anything on each one.

pi-hole

What you need to use Pi-hole at home

To set up Pi-hole in your home network, the usual approach is to use a Raspberry Pi as a dedicated deviceA model like the Raspberry Pi 3 B+ is more than enough for a normal home network, although later models and even some earlier ones also work.

The basic material would be something like the following: a Raspberry Pi (3 B+ or higher)You'll need a microSD card of at least 8 GB, a suitable power supply, an Ethernet cable to connect it to the router, and optionally, a keyboard and monitor for the initial setup if you don't want to do everything via SSH. In some cases, people buy complete kits (for example, from stores like PiHut) where almost everything is already prepared.

It's not essential to have a router of a specific brand, but you will need the router to allow change DNS server This is announced via DHCP to the devices on your network. Many models from manufacturers like TP-Link (Archer, Deco…), Asus, ISP routers, and others offer this option in their settings panel. If you can't change the DNS on the router, you can always configure it manually on each device, although this is more tedious.

In the case of specific routers (such as, for example, a Spectrum Sagemcom Fast 5285, or various TP-Link Archer and Deco models), the process involves accessing their web administration interface Locate the section where the primary DNS server for the LAN's DHCP service is defined. That's where you'll later enter your Pi-hole's IP address.

Prepare the Raspberry Pi before installing Pi-hole

The first technical step is to prepare the Raspberry Pi's operating system. This is typically used Raspberry Pi OS (formerly Raspbian), preferably the Lite version To avoid wasting resources on a graphical interface if you don't need it. If your Raspberry Pi supports it, using the 64-bit version is a good idea.

The usual way is to download the official Raspberry Pi OS image from the Raspberry Pi Foundation website. It is advisable Always download the latest version available, because the link and the edition may change over time, so it doesn't make sense to rely on an old link that you might see in a screenshot.

Once you have the image file, you need to record it on the SD cardOn macOS, this can be done from the command line: first, identify the card's disk with a command like diskutil listAnd when you know what device number it is, you use a command like dd to copy the image to the card. It's a process that requires care, because if you select the wrong disk you could overwrite another one.

If you're using Windows, the easiest way is to use tools with a graphical interface such as Win32 Disk Imager or Balena EtcherThese tools guide you step-by-step through choosing the image and card, reducing the risk of errors. In any case, the goal is the same: to ensure the Raspberry Pi OS image is correctly installed on the microSD card.

When the SD card is ready, insert it into the Raspberry Pi, connect it to a monitor and keyboard (at least the first time), and turn it on. The initial configuration is completed on the first boot.where you can define the username, password and, if needed, some basic system settings.

raspberry pi 4

Enable remote SSH access to the Raspberry Pi

To avoid having the Raspberry Pi always connected to a monitor and keyboard, the usual approach is Enable SSH accessThis way you can manage it from another computer on the network using a terminal or a client like PuTTY on Windows.

The standard way to enable SSH on Raspberry Pi OS is to run the command sudo raspi-configThat setup wizard includes a section called Interfacing Options, where you will find the option to turn the SSH server on or off.

Within that menu, select SSH and check the box to activate it. The system will display a message like “The SSH server is enabled" indicating that you can now connect remotely. From that moment on, as long as the Raspberry Pi is powered on and on the network, it will accept SSH connections."

To find out what IP address the Raspberry Pi has received on your network, you can run the command hostname -IThe result will be something like this. 192.168.XY (For example, 192.168.96.156). That IP address is the one you will use from your PC to connect, for example by typing in a terminal. ssh usuario@192.168.96.156 or by configuring PuTTY with that data.

Remember that the The user is defined during the first boot of the system, and it's the one you'll need to use in SSH sessions. Once you've verified that you can connect without problems, you won't need to have the Raspberry Pi connected to a screen every time you want to make changes.

Pi-hole installation step by step

With the Raspberry Pi ready and accessible via SSH, it's time to install Pi-hole. The most common method involves using a automatic installation script which downloads and prepares everything necessary. To do this, you open an SSH session and execute a command like this:

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

That command downloads and runs the official installer. Pi-hole will install itself over several minutes and will eventually display various configuration screens. It is important to read each step carefully., as it defines key aspects of how your new DNS server works.

One of the fundamental points is to assign a static IP address to the Raspberry within your local network. If you let it change its IP address each time (via DHCP), devices could lose it as their DNS server at some point, so it's best to reserve it. The Pi-hole installer can help you reserve that IP address, although it can also be managed from the router's settings.

Another question the assistant will ask you is what upstream DNS server You want to use it. That is, when Pi-hole receives an unblocked request, which external server should it query? Here you can choose providers like Google (for example, the Google ECS option), Cloudflare, OpenDNS, etc. Choose whichever you prefer; for most users, any of these will suffice.

The remaining initial options usually work well with the default values. So, unless you have very specific needs, you can follow the recommended workflow. At the end, the program will display a screen indicating that the installation has finished successfully and, very importantly, It will teach you the initial password to access the web interface. from Pi-hole. It's a good idea to write down that key or change it immediately.

If you want to set a custom password (or change it later), you can use the command pihole -a -p From the Raspberry Pi console, you can define a new administrator password for the web panel. You can even leave it without a password if you wish, although this last option is not recommended in practice.

pi-hole

Access to the Pi-hole web administration panel

Once the basics are installed and configured, you can access the Pi-hole graphical interface. To do so, open a browser on any device on the network and type the Raspberry's IP address followed by /adminFor example, something like http://192.168.1.xx/admin, or with an additional port if you have customized it on a NAS or container.

Upon entering, you will see the home screen displaying a summary of the statistics: Total DNS queries, how many have been blocked, blocking percentage, most frequently visited domains, etc. To make changes, you will need to click on Login and enter the password you defined or that the installer gave you.

Once inside, you have a side menu from which to access all sections: control panel, blocklist settings, tools, group management, real-time query logging, and more. It's recommended to spend a few minutes browsing. and familiarize yourself with what each section offers before tackling anything serious.

In installations on NAS or other devices, the panel works the same way: the only difference is that, instead of the Raspberry Pi's IP address, you will use the address and port that you have assigned to the Pi-hole service on that machineFor example, if you run it on a NAS with a specific port, you will access it using something like http://192.168.1.xx:puerto/admin.

From this interface you can see in real time which clients are using Pi-hole, which domains are trying to load and which are blocked, providing a A fairly clear view of your network's DNS trafficIt's one of the best ways to understand everything that goes on behind the scenes when you simply open a website or an app.

Configure the router and devices to use Pi-hole

For Pi-hole to work its magic, you need the devices on your network to use it as primary DNS serverThe cleanest way to achieve this is by adjusting the settings on your router so that all devices that obtain an IP address automatically (via DHCP) also receive Pi-hole's IP address as their DNS server.

In practice, this involves accessing your router's administration panel (usually by typing its IP address, something like 192.168.1.1, into your browser) and locating the section for LAN, DHCP, or internal network configurationThere you'll usually find a field called "Primary DNS Server" or something similar. On an Asus router, for example, it's located in the LAN section, DHCP Server tab, where you can enter your Raspberry Pi's IP address as the primary DNS server.

If you use routers from brands like TP-Link (with Archer or Deco ranges, such as C1200, C5400, Deco X20, AX73, etc.), the procedure is similar: you enter the panel, go to the local network or DHCP section and change the Primary DNS to that of Pi-holeEach model has a slightly different menu, but the idea is always the same, and the manufacturer's official documentation usually explains where to adjust that parameter.

Some people choose to put a second DNS, like Google's (8.8.8.8)as a backup. However, this can cause certain devices (especially mobile devices) to preferentially use that secondary DNS, bypassing Pi-hole and significantly reducing its effectiveness. Therefore, if you want more reliable filtering, it's better to Just set Pi-hole's IP address as the primary DNS. on the router, or that the secondary one is another backup Pi-hole if you have a redundant installation.

After changing the DNS on the router, it's advisable to restart devices that obtain their IP address via DHCP (computers, mobile phones, tablets, televisions, etc.) so that they refresh their configuration and Start using Pi-hole's IP address immediately.In the case of devices with a manually configured static IP address, you will have to access the network settings of each device and manually change the primary DNS to the IP address of your Raspberry Pi or NAS.

See which teams are using Pi-hole and network status

One of the most useful sections of the Pi-hole panel is the one that allows Check which devices are connected to the network and which are using the DNS serviceThis can be found in the Tools menu, within the Network section.

On that screen, you can see the list of clients, their IP addresses, names (if detected), the number of requests made, and whether or not they are being filtered. It's a practical way to verify that, for example, your mobile device is actually using Pi-hole and isn't stuck with outdated or alternative DNS servers.

In addition, the main panel displays the total number of blocked queries, the most frequently rejected domains, and the clients that generate the most traffic. This information is very useful for diagnosing problems or detect particularly "chattering" devices that send many requests to analytics or advertising services.

If you notice that a device on your network is missing from the list or has no traffic through Pi-hole, it's usually best to check its network configuration. Sometimes, certain devices have a fixed DNS server configured by default or use protocols like DNS-over-HTTPS, which can bypass traditional network-level filtering.

Manage and update block lists (Adlists)

The heart of the Pi-hole blockade is the lists of domains that it decides to blockThese lists are managed from the Group Management > Adlists section of the administration panel. There you can add new sources, activate or deactivate existing ones, and extensively customize their behavior.

There are many websites on the internet dedicated to compiling blocklists for Pi-hole and similar programs. One very popular reference is... firebog.netwhere some lists are highlighted in green as recommended. Many users choose to use only these or combine them with another reliable source. Another well-known option is filterlists.comwhere you can also search for lists based on the type of content to block.

Ideally, you shouldn't go overboard adding dozens of lists haphazardly, because too many sources can lead to false positives or slow down updates. A good strategy is start with the recommended basic lists And, if you notice any specific type of advertising slipping through, look for more specific lists for that type of content.

The lists themselves are updated automatically; that is, their maintainers add or remove domains without you having to edit anything manually. However, when you add new lists or want to force an update of the entire set, you can go to the Tools menu and use the option Update Gravity, which is responsible for downloading and consolidating all blocking information.

Thanks to these lists, Pi-hole will be able to maintain a fairly high level of filtering without you having to constantly check domains one by one. Even so, you can always use local whitelists or blacklists to fine-tune the behavior in very specific cases.

Configuration backups with Teleporter

Once you've customized Pi-hole to your liking, with lists configured, groups created, rules customized, and everything working properly, it's highly recommended. back up the settingsThis way, if a problem arises in the future or you need to reinstall, you can recover your environment without starting from scratch.

To make these copies, the built-in tool called teleportersYou can access this from the administration panel in the Settings section. There you will find the option to export the data and download a backup file with all the relevant settings.

The copying process is simple: you choose which parts of the configuration you want to include (lists, rules, groups, etc.) and download the resulting file to your computer. You can then save this file in a safe place and use it whenever you need. restore Pi-hole state after a reinstallation or a device change.

If you ever need to restore, return to the same Teleporter section, select the backup file from Browse, and click Restore. You can choose to recover everything or only specific items, which offers considerable flexibility if you only want to revert to a particular aspect.

With this set of steps—installing the system, enabling SSH, setting up Pi-hole, configuring the router, updating the lists, and securing backups—you will have a Pi-hole installation ready for everyday useBlocking much of the advertising and tracking on all your WiFi-connected devices, improving your browsing experience and often also page loading speed by removing those annoying elements.