Install Pi-Hole on Raspberry Pi (Free Ad Blocker in 15 min)

1. Download the latest version of Raspbian onto your computer.

2. Insert your SD card into your computer and use the software of your choice to write the Raspbian image to the SD card.

3. Insert the SD card into your Raspberry Pi and power it up.

4. Connect your Raspberry Pi to your router via an Ethernet cable.

5. Log into your Raspberry Pi using SSH.

6. Update your Raspberry Pi by running the following command: sudo apt-get update && sudo apt-get upgrade

7. Install Pi-Hole by running the following command: curl -sSL https://install.pi-hole.net | bash

8. Follow the on-screen instructions to complete the installation.

9. Once the installation is complete, you will be given an IP address.

10. Log into your router and set the DNS server to the IP address given by Pi-Hole.

11. Log into the Pi-Hole web interface and configure the settings as desired.

12. Reboot your Raspberry Pi and test the ad blocking by visiting a website with ads.

13. Enjoy your ad-free browsing experience!
[ad_1]

Blocking ads and pop-ups on all of your devices can sometimes take a lot of time and effort. Today, I’ll show you how to install an ad blocker for your entire network in 15 minutes. We’ll use Pi-Hole, which is a famous ad-blocker for Raspberry Pi.

Pi-Hole is a free and open-source ad-blocker that can be easily installed and set up on Raspberry Pi. The source code is available on GitHub, and it can be installed on Raspberry Pi OS with one command line: curl -sSL https://install.pi-hole.net | sudo bash

In this post, I’ll start by introducing Pi-Hole, then show you how to install and configure it on your network.

By the way, Pi-Hole is one of the many projects I introduce in my book “Master your Raspberry Pi in 30 days“. So, if you are interested in improving your skills on Raspberry Pi, I highly recommend it. It’s a 30-day challenge to take you from beginner to master, with step-by-step tutorials and many projects to practice along the way.

Pi-Hole Presentation

pihole logo

What is Pi-Hole?

As I said in the introduction, Pi-Hole is a free and open-source ad-blocker.
It’s different from AdBlock or other browser extensions because it’s directly on the network, it’s a DNS ad-blocker.

Pi-Hole has existed since 2014, and it works on most Linux distributions.
It’s available for Debian-like distributions (Debian, Raspberry Pi OS, Ubuntu) and also Fedora/CentOS.

By the way, I have a tutorial on how to set up Pi-Hole on Ubuntu here. Whether you’re using a Raspberry Pi or another computer, it might be interesting for the Ubuntu users reading this.

What is a DNS Ad-Blocker?

You probably know or use AdBlock to get the same results, but it depends on your browser.
If you have AdBlock on Google Chrome and switch to Firefox, ads are back.
Also, it isn’t possible to use it on mobile (or at least with any system/browser).

A DNS ad-blocker is easier to manage because once you install Pi-Hole, you can use it directly with any device on the same network.
Just set your DNS server with the Raspberry Pi IP, and that’s it, you won’t have ads anymore.

I recently tested AdGuard Home, which is an alternative to Pi-hole. You can read this article to find out the differences and pick the one that’s best for you.

Installing Pi-Hole On Raspberry Pi

Let’s move on to the installation process. It’s pretty straightforward.

Hardware

Pi-Hole is a lightweight software, and it’s designed especially for Raspberry Pi.
So, you can use it with any Raspberry Pi model.

In my case, I’m using my Raspberry Pi Zero for this (you can use this kit for example) and it works well.

If you don’t have a Raspberry Pi yet, you can follow the same procedure with a Linux computer, or even a virtual machine running on Linux.

Operating system

Pi-Hole works on Raspberry Pi OS, so there is no need to take a specific SD card or buy a Raspberry Pi just for this.
You can use any Raspberry Pi you have.
If you already have one running all day, you can use that one.

If you need to install Raspberry Pi OS, check my guide here on how to install it on Raspberry Pi.
Raspberry Pi OS Lite is fine if you don’t need the graphical interface for something else.

Before continuing, make sure you have:

  • Raspberry Pi OS installed.
  • A working network.
    Wired or wireless is ok on a small network, as it’s just for DNS requests.
  • An up-to-date system with the latest packages:
    sudo apt update && sudo apt upgrade -y
  • SSH access enabled:
    sudo service ssh start

And that’s it, you’re ready to go!

Are you a bit lost in the Linux command line? Check this article first for the most important commands to remember, and a free downloadable cheat sheet so you can have the commands at your fingertips.

Downloading and Installing Pi-Hole

Pi-Hole is available on this GitHub repository, and they have a one-line command to easily install it.

Ok, it was a long wizard, but basically, you can just keep the default value for each screen.
You can change everything later with the web interface.

It looks like the developer love to shuffle the questions order, so I’m sorry if your setup wizard was not exactly in the same order as mine :-).

After this, the installation process continues by downloading and installing new packages based on your choices.

Don’t miss the last screen as it will give you the web interface address and the login password:

I’ll explain the web interface in the next section.
But before that, we need to tell the clients to use the new DNS server.

Client Configuration

DHCP Configuration

The easiest way to configure all devices at once is to change your DHCP server configuration.
At home, it’s probably your Internet router that takes this role.

I won’t explain this in detail, as it’s different on each router.
It can be in the DHCP settings or the DNS settings.

For me, it’s in the DNS settings.

The only thing to do is to remove all values and set the primary DNS server as 192.168.1.17.
That’s my Raspberry Pi IP address, so remember to set it with your own.
Don’t set a secondary IPv4 DNS server, except if you have two Raspberry Pi with Pi-Hole on your network.

This way, any device using DHCP will now use the Pi-Hole ad-blocker from your network as a DNS server.
It can take a few hours to update the device settings on all devices, be patient, or disconnect/reconnect them manually.

Static Configuration

If you don’t have access to these settings or want to make a try first, you can edit only your computer settings:

On Windows 10:

  • Right-click on the “Start Menu” and choose “Network Connections”.
  • Then click on “Change adapter settings”.
  • Right-click on your current connection and choose “Properties”.
  • Double-click on “Internet Protocol Version 4 (TCP/IPv4)”.
  • Set the DNS server to static and enter your Raspberry Pi IP Address.
    Keep the secondary DNS server empty.

On Windows 11:

  • Open the system settings from the main menu.
  • Click on “Network & Internet”.
  • Find your current connection (Wi-Fi or Ethernet) and click on it to view the settings:
  • Click on “Edit” to change the DNS server, and set it to your Raspberry Pi IP address.
  • Save and exit, the ad blocker should be active now.

On Linux and Mac OS:

  • If you have a graphical interface, you’ll find the network settings in the System Preferences.
  • If not, you can edit the /etc/resolv.conf file and replace the current DNS server with the Raspberry Pi IP address.

On mobile, it’s in your Wi-Fi settings.
Click details or edit the network on a network to see the DNS configuration.

Pi-Hole Web Interface

Pi-Hole comes with an excellent web interface, let’s check it out now.

First Login

To access the web interface, open your browser and go to http://<RASPBERRYPI_IP>/admin.
In my case, it’s http://192.168.1.17/admin.

If you didn’t note the IP address during the installation wizard, you can find it with “ifconfig.”

Warning: Pi-Hole will use the HTTP port (80) by default. If you already had a web server on your Raspberry Pi, you need to change the port for one of them.

Once on the web page, click Login and enter the password you got previously.
If everything is correct, you’ll get something like this:

The Pi-Hole web interface

On this page, you can see all the statistics about your Internet usage:

  • Total queries: the number of requests you have made.
  • Queries blocked: the number of requests blocked.
  • Percent Blocked = queries blocked / total queries.
  • Domains on Blacklist: the number of domain names you have on the blacklist.

There are also graphs about queries and clients’ evolution in recent hours.
Two pie charts show data about query types.
And below (we don’t see it in the picture), it lists the top domains and top blocked domains, and the same thing for clients.

That’s pretty cool, and it’s only the first page.

In the main menu you’ll find links to the other pages and sections:

  • Dashboard: the page we just saw.
  • Query Log: if enabled, all the queries you made and if Pi-Hole blocked them or not.
  • Long-term data: the dashboard shows data from the last 24 hours, but in this section, you can specify the date range.
  • Whitelist: here you can add domains to the whitelist (if they are on a blacklist and you don’t want to block them). For example, I use Google Analytics for this website, and it’s on the blacklist, so I added the URL here.
  • Disable: Sometimes you may need to disable Pi-Hole for a few minutes or permanently to do something specific on your computer. This is where you can do it.
  • Tools: a bunch of tools to debug Pi-Hole. I will let you discover this part.
  • Settings: all the configuration menus, which we’ll come to in the next paragraph.
  • Log out / Donate / Help: these should be clear.

If you have any questions about one menu item, leave a comment in the community and I’ll try to help you.

Settings

Let’s look especially at the settings part now.
When you click on the “Settings” menu item, you’ll get 6 tabs with settings forms:

You can edit here all the things you previously chose in the installation wizard.

  • System: In this first tab, you can check information about the network and the Pi-Hole version and usage. You also have a “Danger Zone” to restart services, reboot Raspberry Pi, or clear logs.
  • DNS: DNS tab is where you can change your DNS providers and configure more advanced DNS settings.
  • DHCP: This tab allows you to enable a DHCP server on Pi-Hole. That’s another way to configure clients if your current router doesn’t do this. Don’t forget to disable the old DNS server if you want to try this.
  • API / Web interface: The next tab is for various settings about the interface. You can mask domains for the dashboard and customize the interface display.
  • Privacy: In this tab, you can change the privacy level we saw in the installation wizard to increase or decrease the privacy level on the interface.
  • Teleporter: Finally, what they call “Teleporter” is just an Import/Export tool, to move the configuration from one Raspberry Pi to another.

Pi-Hole Tips

Before ending this tutorial, you need to know a few other things about Pi-Hole.

Updating the Blacklist

As you can guess, domain blacklists change every day.
Like antivirus software, you need to update them regularly to maintain good protection.

To do this, go to Tools > Update Gravity and click on Update.

Pi-Hole will download each blacklist file from the specified sources and reload the configuration.

Updating the Software

The other thing you need to update is the software.
Pi-Hole is releasing updates and fixes regularly, so you need to update it.

To do this, the procedure is simple:

  • Connect to your Raspberry Pi via SSH.
  • Type this command:
    sudo pihole -up 
  • You’ll get something like this:
    pi-hole update
  • In my case, I’m already up to date, but if there is an update, you’ll see it here.

Is there a way to use Pi-Hole to block more than ads domains?

From the Pi-Hole interface, you can add custom domain names and lists. So, you can use it to block any domains: not safe for kids, specific domains, or websites known to install malware.

What can I do if it blocks a useful website?

If you have websites that you often use not working after the Pi-Hole configuration, you can add the domain name in the whitelist menu to unblock it.

Video

Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums.

Conclusion

That’s it, you know everything you need about how to install Pi-Hole on Raspberry Pi.
I hope this will help you remove ads and block undesired domains.

If you have any other questions, leave a comment in the community, and I’ll try to answer you.
Thanks to share this post by using the buttons below!

Additional Resources

Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now.

Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
Download the e-book.

VIP Community
If you just want to hang out with me and other Raspberry Pi fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Create, understand, and improve any Python script for your Raspberry Pi.
Learn the essentials step-by-step without losing time understanding useless concepts.
Get the e-book now.

You can also find all my recommendations for tools and hardware on this page.

[ad_2]

Install Pi-Hole on Raspberry Pi (Free Ad Blocker in 15 min)

Pi-Hole is a free and open-source ad-blocking software that can be installed on a Raspberry Pi. It is a network-level advertisement and tracker blocking application that can block ads for all devices on your network. It is easy to install and can be done in just 15 minutes.

Step 1: Install Raspbian OS

The first step is to install the Raspbian OS on your Raspberry Pi. You can download the latest version of Raspbian from the official Raspberry Pi website. Once you have downloaded the image, you can use a tool like Etcher to write the image to your SD card.

Step 2: Connect to the Raspberry Pi

Once you have installed the Raspbian OS, you can connect to the Raspberry Pi using SSH. You can use a tool like PuTTY to connect to the Raspberry Pi. Once you are connected, you can run the following command to update the system:

sudo apt-get update && sudo apt-get upgrade -y

Step 3: Install Pi-Hole

Once the system is updated, you can install Pi-Hole using the following command:

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

This will start the installation process. You will be asked to select an interface to use for the Pi-Hole installation. You can select the default option or select a different interface if you want. You will also be asked to select a DNS provider. You can select the default option or select a different provider if you want.

Step 4: Configure Pi-Hole

Once the installation is complete, you can configure Pi-Hole using the web interface. You can access the web interface by going to http://pi.hole in your web browser. You can then configure the settings as per your requirements. You can also add additional blocklists to block more ads.

Step 5: Test Pi-Hole

Once you have configured Pi-Hole, you can test it by visiting a website that has ads. You should see that the ads are blocked. You can also use a tool like Pingdom to test the performance of your website with Pi-Hole enabled.

Conclusion

Pi-Hole is a great way to block ads on your network. It is easy to install and configure, and can be done in just 15 minutes. With Pi-Hole, you can block ads for all devices on your network, and improve the performance of your website.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00