Turn your Raspberry Pi into an ad blocker

This article will show you how to convert a Raspberry Pi into an ad blocker all over the network, using Pi-Hole. Once completed, you will be able to block ads on any device connected to the network.

While there are many ad-blockers that can remove ads from your computer, they rarely work on other devices, such as smartphones or tablets.

This article will show you how to convert a Raspberry Pi into an ad blocker all over the network, using Pi-Hole. Once completed, you will be able to block ads on laptops, computers, smartphones, tablets and any other devices connected to the network.

Block ads for the whole network with Raspberry Pi

  1. Things to prepare
  2. Install Pi-Hole on Raspberry Pi
  3. Choose a DNS provider
  4. Which blacklist should Pi-Hole use?
  5. Choose Internet Protocol IPv4 or IPv6 (or both)?
  6. Configure static IP address
  7. Tracking Pi-Hole with web administration interface
  8. Log Pi-Hole data
  9. Log in to your Pi-Hole account
  10. Resovle problem
  11. Update the router: Create an ad blocker all over the network
  12. How to block online ads on specific devices
    1. 1. Windows
    2. 2. Linux
    3. 3. macOS
    4. 4. iPhone
    5. 5. Android

Things to prepare

To complete this tutorial, you will need:

  1. Raspberry Pi runs Raspbian. If Raspbian is not installed, download the latest version and flash it using Etcher.
  2. The power cable is compatible with the Raspberry Pi
  3. External keyboard and how to attach it to a Raspberry Pi
  4. HDMI or micro HDMI cables, depending on the Raspberry Pi model
  5. External screen
  6. Connect Ethernet cable or WiFi

After assembling the tools, you are ready to create ad blockers across the network.

Install Pi-Hole on Raspberry Pi

First, attach an external keyboard, monitor, and any other peripheral to the Raspberry Pi, then attach the Pi to the power source.

As soon as the Raspberry Pi boots up, you're ready to download the Pi-Hole installation script. Just launch Terminal (by clicking the Terminal icon in the Raspbian toolbar), then enter the following command in the Terminal window:

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

Press Enter. Raspbian will download the script and start the device configuration process to use Pi-Hole.

After a few moments, the Pi-Hole setup screen will automatically launch.

After running the installation script, the Pi-Hole setup dialog will automatically launch.

Keep pressing Enterto switch through the introductory screens until you are asked to let the Pi-Hole work over WiFi ( wlan0 ) or Ethernet ( eth0 ).

Turn your Raspberry Pi into an ad blocker Picture 1Turn your Raspberry Pi into an ad blocker Picture 1 Use the arrow keys to select wlan0 or eth0

Use the arrow keys to select wlan0 or eth0 (this guide is using WiFi) and press Enter.

Choose a DNS provider

You need to choose an upstream DNS provider, which will be responsible for answering queries for non-advertising domains.

Pi-Hole supports the following pre-installed DNS providers, but you can enter your provider by selecting Custom.

  1. Google (ECS)
  2. OpenDNS (ECS)
  3. Level3
  4. Comodo
  5. DNS.WATCH
  6. Quad9 (filtered, DNSSEC)
  7. Quad9 (unfiltered, DNSSEX)
  8. Quad9 (filtered + ECS)
  9. Cloudflare

This guide is using Google, but you can choose any DNS provider you like.

Which blacklist should Pi-Hole use?

Specifies a list that Pi-Hole should use to identify and block unwanted content.

Turn your Raspberry Pi into an ad blocker Picture 2Turn your Raspberry Pi into an ad blocker Picture 2 Specifies a list that Pi-Hole should use to identify and block unwanted content

Unless you have a specific reason to change these settings, leave the default options as they are.

Choose Internet Protocol IPv4 or IPv6 (or both)?

It doesn't matter whether you choose IPv4 or IPv6, but if you want to block as many ads as possible, you should choose both IPv4 and IPv6.

Configure static IP address

Use current network settings as static address Pi-Hole. Assuming you are very satisfied with the information displayed on the screen, use the arrow keys to select Yes , then press Enter.

Read the disclaimer carefully and if you agree, select OK.

Tracking Pi-Hole with web administration interface

You will be asked if you want to install the Pi-Hole web administration interface. This interface provides insight on how the Pi-Hole works online, so you should choose to install the web interface when prompted.

Turn your Raspberry Pi into an ad blocker Picture 3Turn your Raspberry Pi into an ad blocker Picture 3 You should choose to install the web interface when prompted

If you are installing the web management interface, you should also install lighttpd web server when prompted.

Log Pi-Hole data

You can choose to disable Pi-Hole logging capabilities, but you should enable it, as they provide some useful information.

You will be prompted to select the privacy mode for FTL, this is the level of information that will be included in Pi-Hole statistics. Choose one of the following options:

  1. Show everything : Show everything.
  2. Hide domains : Show and store all domains as hidden.
  3. Hide domains and clients : Display and store all domains as hidden and the client is 0.0.0.0.
  4. Anonymous mode : Hide all details except the most anonymous statistics.
  5. Disabled statistics : Disable all statistical processing, including query counters.

Log in to your Pi-Hole account

The setup dialog box will display the address of the Pi-Hole web administration interface and the password you need to log into this interface. Please record this information!

If you access the provided URL, you will encounter the standard Pi-Hole web interface and be able to log in with your password.

The web administration interface is divided into the following sections:

  1. Query log : This will display the most recent queries that have been made to the DNS server.
  2. Whitelist : You can specify domains that Pi-Hole should never block.
  3. Blacklist: Are some ads still trying to get past Pi-Hole? If you can identify the domain responsible for these fake ads, you can add it to your Pi-Hole blacklist.
  4. Disable: This is where you can temporarily or permanently disable Pi-Hole to see all your favorite ads again!
  5. Update lists: Make sure you have the latest version of the Pi-Hole ad blocking list by activating manual updates.
  6. Query adlists : Use this tool to check if a specific URL is included in the Pi-Hole ad blocking list.
  7. Tail pihole.log : This tool allows you to check the Pi-Hole log file, so you can see exactly how Pi-Hole is handling incoming requests.
  8. Settings : You can make some changes to the Pi-Hole configuration, including the upstream DNS provider you want to use.

This is only a brief overview of the Pi-Hole web administration interface. It is well worth the time to explore this interface in more detail!

Resovle problem

While configuring Pi-Hole, you may encounter the following error in the Terminal window:

'Could not resolve host FTL Engine not installed.'

If you see this message, run the following Terminal command:

sudo nano /etc/resolv.conf

This command will launch the resolv.conf file in the Nano editor. You need to add the IP address of the selected DNS provider to the resolv.conf file. For example, this tutorial is using Google as a DNS provider, so a quick search on Google suggests that 8.8.8.8  should be added to resolv.conf:

nameserver 8.8.8.8

To save the changes, use the shortcut Ctrl+ O, then press Ywhen prompted.

Close resolv.conf using the Ctrl+ shortcut X.

Relaunch the Pi-Hole setup conversation by running the following Terminal command:

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

You can now complete the setup dialog box without any errors.

Update the router: Create an ad blocker all over the network

You are ready to update your device or router to use Pi-Hole. If you want to block ads on all devices connected to the network, you'll need to change the router's DNS settings to point to the Raspberry Pi device.

The process of changing the router's DNS settings will vary depending on the router model, but overall, you'll need to:

  1. Go to the admin page of the router.
  2. Log in with your username and password. If you do not know this information, you most likely used the default manufacturer's username and password. Find this information on the manufacturer's website, or in the documentation that came with the router.
  3. Find any tab, menu or section containing the words 'DNS server' or 'DHCP server'. Note that these settings may be hidden in the Advanced setup section .
  4. Update the router's primary DNS server to the Raspberry Pi's IP address. If you don't know this address, you can access it by opening the Raspbian window from the Terminal and running the following command:
hostname -I

For instructions on how to update your router's DNS settings, check the manufacturer's website or the documentation that came with the router.

How to block online ads on specific devices

You can also change DNS settings for specific devices and operating systems.

1. Windows

To update DNS settings on Windows:

  1. Launch Control Panel.
  2. Navigate to Network and Internet> Network and Sharing Center> Change adapter settings .
  3. Select the connection you want to configure.
  4. Right-click Local Area Connection> Properties .
  5. Select the Networking tab .
  6. Select TCP / IPv4 or TCP / IPv6.
  7. Navigate to Properties> Advanced> DNS and then click OK.
  8. Select Use the following DNS server addresses .
  9. Replace the addresses in this section with the IP address of the Raspberry Pi.

Windows PC is now set up to use the Pi-Hole ad blocker.

2. Linux

If you are a Linux fan, you will need:

  1. Navigate to System> Preferences> Network Connections .
  2. Select the connection you want to configure, then click Edit.
  3. Select either the IPv4 Settings or IPv6 Settings tab.
  4. In the DNS server field , enter the IP address of the Raspberry Pi.
  5. Save the changes by clicking Apply.

Alternatively, you can update your DNS settings by opening the /etc/resolv.conf file .

3. macOS

To update DNS settings in macOS:

  1. Select the Apple logo on the Mac toolbar.
  2. Navigate to System Preferences> Network .
  3. Select the connection you want to edit.
Turn your Raspberry Pi into an ad blocker Picture 4Turn your Raspberry Pi into an ad blocker Picture 4 Select the connection you want to edit
  1. Click on Advanced .
  2. Select the DNS tab .
Turn your Raspberry Pi into an ad blocker Picture 5Turn your Raspberry Pi into an ad blocker Picture 5 Select the DNS tab
  1. Click the + icon and enter the IP address of the Raspberry Pi.
  2. Save the changes by clicking Apply> OK .

Pi-Hole will collate all your requests with the blacklist and block as many ads as possible.

4. iPhone

If you own an iPhone or iPad, then:

  1. Launch the Settings application .
  2. Select WiFi and tap on your home network in the list.
  3. Select the DNS field .
  4. Delete all existing DNS servers and replace them with the Raspberry Pi IP address.

5. Android

To block ads on Android:

  1. Launch the Settings application .
  2. Choose WiFi.
  3. Press and hold on the WiFi network you want to update.
  4. Select Modify network> Advanced options .
  5. Click DHCP , then Static.
  6. In DNS 1 , enter the Raspberry Pi IP address.
  7. Click Save.

While using the Raspberry Pi as an ad blocker, it can also be used as a WiFi access point or personal web server.

3.5 ★ | 2 Vote