Ubuntu 22.04 Tutorials

How to Install Pi-Hole On Ubuntu 22.04: Step-by-Step Guide

Learn how to install Pi-Hole on Ubuntu 22.04 and enjoy ad-free browsing. Follow our step-by-step guide for seamless setup and enhanced privacy.

Introduction

In this comprehensive guide, we will walk you through the process of installing the Pi-Hole on Ubuntu 22.04. Pi-Hole is a powerful network-wide ad blocker that functions as a DNS sinkhole. By blocking ads at the network level, Pi-Hole improves the overall browsing experience across all devices connected to your network. This step-by-step tutorial will help you set up Pi-Hole on your Ubuntu 22.04 system, ensuring a seamless and ad-free browsing experience. So, let’s dive in and learn how to install Pi-Hole!

How to Install Content Filter Pi-Hole On Ubuntu 22.04

Prerequisites

Before we begin, make sure you have the following prerequisites in place:

  1. Ubuntu 22.04 installed on your system.
  2. For a virtual machine: 50GB Storage, 2GB Ram, 1 vCPU
  3. A stable internet connection.
  4. Basic knowledge of the command line interface (CLI).

Installing Pi-Hole

First off, the obvious, log into your Ubuntu 22.04 Server, if you’re using a windows computer, you can use PowerShell to connect.

SSH yourusername@ubuntuserveripaddress

Step 1: Update System Packages

The first step is to update the system packages to their latest versions. Open a terminal window and execute the following command:

sudo apt update && sudo apt upgrade -y

This command will update the package lists and upgrade the installed packages to their latest versions.

Step 2: Install Dependencies

Pi-Hole relies on several dependencies to function properly. To install these dependencies, run the following command:

sudo apt install curl git -y

Step 3: Download Pi-Hole Installer

Next, we need to download the Pi-Hole installer script from the official GitHub repository. Use the following command to download the script:

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

Step 4: Configure Pi-Hole

Once the installer script finishes downloading, you will be presented with a configuration screen. Here, you can customize various settings such as upstream DNS servers and blocklists. You can either choose the default settings or modify them according to your preferences.

Step 5: Complete the Installation

After configuring Pi-Hole, the installer will start the installation process. This may take a few minutes, depending on your system’s speed and internet connection. Once the installation is complete, you will see a success message on your screen.

Remember to Write down your Pi-hole admin login password.

How to Install Content Filter Pi-Hole On Ubuntu 22.04

Step 6: Configure Ubuntu Firewall With Required Ports

To open port 80 on the firewall in Ubuntu, you can use the ufw (Uncomplicated Firewall) command-line tool. Follow these steps:

  1. Check the current status of the firewall:
sudo ufw status
  1. Allow incoming connections on port 80, 22, 53:
sudo ufw allow 80
sudo ufw allow 22
sudo ufw allow 53
  1. If the firewall is inactive, enable it:
Sudo ufw enable
  1. Verify the changes made:
sudo ufw status

After executing these commands, port 80 80, 22, 53 will be open on the firewall, allowing incoming connections.

Step 7: Access Pi-Hole Admin Console

To access the Pi-Hole admin console, open a web browser on any device connected to your network and enter the following URL:

http://<your-pi-hole-ip>/admin

Check your ethernet name before moving to the next Shell command and adjust as needed.

ifconfig -a | grep -oP '^\w+(?=: flags)'

Replace <your-pi-hole-ip> with the IP address of the machine where you installed Pi-Hole. If you’re unsure about the IP address, you can find it by running the following command on the machine:

ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'

Frequently Asked Questions (FAQs)

What is Pi-Hole?

Pi-Hole is a network-wide ad blocker that acts as a DNS sinkhole. It blocks advertisements at the network level, providing an ad-free browsing experience across all devices connected to your network.

Why should I use Pi-Hole?

Pi-Hole offers several benefits, including:

  • Improved browsing experience.
  • Ad Filtering.
  • Reduced data consumption.
  • Enhanced privacy by blocking tracking domains.
  • Network-wide ad blocking for all connected devices.

Can I install Pi-Hole on any operating system?

Pi-Hole is compatible with various operating systems, including Ubuntu, Debian, Fedora, and CentOS. However, this guide specifically covers the installation process on Ubuntu 22.04.

How can I update Pi-Hole?

To update Pi-Hole to the latest version, simply run the following command:

pihole -up

This command will check for updates and apply them if available.

How To Automate Pi-Hole Updates?

To create a systemd service that runs the pihole -up command daily, follow these steps:

  1. Open a terminal window.
  2. Create a new systemd service unit file using a text editor. For example:
sudo nano /etc/systemd/system/pihole-update.service
  1. Add the following content to the file:
[Unit]
Description=Pi-Hole Update Service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/pihole -up

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=multi-user.target

This configuration sets the service to run the pihole -up command as a one-shot task, schedules it to run daily, and ensures it persists across system reboots.

  1. Save the file and exit the text editor.
  2. Reload systemd to recognize the new service:
sudo systemctl daemon-reload
  1. Start the service:
sudo systemctl start pihole-update.service
  1. Enable the service to run at boot:
sudo systemctl enable pihole-update.service

Now, the pihole -up command will automatically run daily as a systemd service. You can check the status of the service using systemctl status pihole-update.service.

Change Pi-Hole Login Password

To change your Pi-Hole Login password, once you execute the command you will be prompted for your new password and to confirm the password.

pihole -a -p

Can I whitelist specific websites in Pi-Hole?

Yes, you can whitelist specific websites in Pi-Hole. By whitelisting a website, you allow its advertisements and tracking scripts to bypass Pi-Hole’s filters. To whitelist a website, access the Pi-Hole admin console, navigate to the Whitelist section, and add the desired domain.

Is Pi-Hole free to use?

Yes, Pi-Hole is an open-source project and is completely free to use. However, donations are highly appreciated to support the development and maintenance of the project.

Conclusion

Congratulations! You have successfully installed Pi-Hole on your Ubuntu 22.04 system. By following this guide, you have taken a significant step towards enjoying an ad-free browsing experience across your entire network. Pi-Hole’s network-wide ad blocking capabilities will not only improve your browsing speed but also enhance your privacy and security. Start exploring Pi-Hole’s admin console and customize it to suit your preferences. Say goodbye to annoying ads and enjoy a cleaner internet experience!

I hope this article was helpful!  You can find more here: Ubuntu Tutorial Articles

author avatar
Patrick Domingues

3 Comments

  1. Thanks for the guide, though I’m stuck at install with the below error. I have searched and cannot find a solution that works. I’ve checked the pi-hole install cert and it’s good, my date & time are correct. Any recommendations?

    scott@PIHOLE:~$ curl -sSL https://install.pi-hole.net | bash
    curl: (60) SSL: no alternative certificate subject name matches target host name ‘install.pi-hole.net’
    More details here: https://curl.se/docs/sslcerts.html

    curl failed to verify the legitimacy of the server and therefore could not
    establish a secure connection to it. To learn more about this situation and
    how to fix it, please visit the web page mentioned above.
    scott@PIHOLE:~$

    1. To fix this problem, you can try the following steps:

      Verify your internet connection: Ensure that your internet connection is stable and functioning properly.

      Update curl: Make sure you have the latest version of curl installed on your system. You can try updating curl to see if it resolves the issue.

      Update the certificate authorities: It’s possible that your system’s certificate authorities are outdated. Try updating them using the appropriate method for your operating system.
      sudo apt update
      sudo apt install ca-certificates
      sudo update-ca-certificates
      sudo dpkg-reconfigure ca-certificates

      Temporarily disable SSL verification: As a last resort, you can use the -k or --insecure flag with curl to disable SSL verification. However, please note that this is not recommended for security reasons, as it bypasses certificate validation.

      Double check your physical firewall connected to the internet is not processing SSL / HTTPS in any weird ways.

      Thank you,
      Patrick Domingues

      1. Thanks for the input. Shortly after my post, I discovered there was a problem with curl in the latest OS update. They quickly re-packaged an update and not causing an issue now.

Leave a Comment

Stay Informed

Receive instant notifications when new content is released.