UbuntuUbuntu Based

How To Install Pi-Hole on Ubuntu 24.04 LTS

Install Pi-Hole on Ubuntu 24.04

In today’s digital age, advertisements and trackers have become ubiquitous, often compromising our online experience and privacy. Pi-Hole, a powerful open-source network-level ad blocker, offers an effective solution to mitigate these issues. By acting as a DNS sinkhole, Pi-Hole blocks ads and trackers across all devices on your network, enhancing your browsing speed, reducing data consumption, and safeguarding your privacy. This guide provides a detailed walkthrough on how to install Pi-Hole on Ubuntu 24.04 LTS (Noble Numbat), ensuring a seamless setup and optimal performance.

Ubuntu 24.04 LTS, the latest long-term support release, provides a stable and robust platform for deploying Pi-Hole. Whether you’re a home user seeking to improve your family’s online experience or a small business aiming to enhance network efficiency, Pi-Hole on Ubuntu 24.04 LTS offers a versatile and reliable solution. Let’s dive into the installation process.

Prerequisites

Before proceeding with the installation, ensure your system meets the necessary prerequisites. This section outlines the hardware, network, and software requirements for a successful Pi-Hole deployment on Ubuntu 24.04 LTS.

System Requirements

Hardware Specifications: Pi-Hole is lightweight and can run on modest hardware. However, a stable and responsive system is crucial for optimal performance. Recommended hardware specifications include:

  • Processor: A minimum of a 1 GHz CPU (single-core) is sufficient, but a multi-core processor is preferable for handling more network traffic.
  • Memory: At least 512 MB of RAM. 1 GB or more is recommended for larger networks or more extensive blocklists.
  • Storage: 16 GB of storage. This provides ample space for the operating system, Pi-Hole software, and log files.

Network Requirements: A reliable network connection is essential for Pi-Hole to function effectively. Key network requirements include:

  • Stable Internet Connection: A consistent internet connection ensures that Pi-Hole can retrieve updated blocklists and resolve DNS queries efficiently.
  • Router Access: Access to your router’s configuration panel is necessary to set Pi-Hole as the primary DNS server for your network.

Static IP Address Necessity: A static IP address is crucial for Pi-Hole to function reliably. A static IP ensures that the Pi-Hole server’s address remains constant, preventing network devices from losing access to the ad-blocking service. You can configure a static IP address directly on the Ubuntu server or through your router’s DHCP reservation settings.

Required Software

Ubuntu 24.04 LTS Server ISO: Download the Ubuntu 24.04 LTS Server ISO image from the official Ubuntu website. Using the server version ensures a minimal footprint and reduces unnecessary overhead.

Git Installation: Git is required to clone the Pi-Hole repository, providing an alternative installation method. Install Git using the following command:

sudo apt update
sudo apt install git

Terminal Access: Ensure you have terminal access to your Ubuntu 24.04 LTS server. This can be achieved via SSH or by directly accessing the terminal if you’re on a desktop environment.

Pre-Installation Setup

Before installing Pi-Hole, it’s essential to perform some pre-installation tasks to ensure a smooth and trouble-free setup. This section covers updating the system and configuring the network.

System Updates

Update Package Repositories: Begin by updating the package repositories to ensure you have the latest software versions. Use the following command:

sudo apt update

Upgrade Existing Packages: Next, upgrade the existing packages to their latest versions. This step resolves potential dependency issues and enhances system stability. Execute the following command:

sudo apt upgrade -y

Network Configuration

Static IP Configuration Steps: Configuring a static IP address is crucial for Pi-Hole’s consistent operation. There are two primary methods for setting a static IP: directly on the Ubuntu server or via DHCP reservation on your router.

To configure a static IP on the Ubuntu server, edit the network configuration file. The file may vary based on your network configuration (e.g., /etc/network/interfaces or /etc/netplan/). Here’s an example using /etc/netplan/:

sudo nano /etc/netplan/01-network-config.yaml

Modify the file to include the following (adjust IP addresses, gateway, and DNS servers to match your network settings):

network:
  version: 2
  renderer: networkd
  ethernets:
  eth0:
  dhcp4: no
  addresses: [192.168.1.100/24]
  gateway4: 192.168.1.1
  nameservers:
  addresses: [127.0.0.1, 8.8.8.8]

Apply the changes:

sudo netplan apply

DHCP Reservation Alternative: Alternatively, configure a DHCP reservation on your router. This method assigns a static IP address to the Pi-Hole server based on its MAC address. Refer to your router’s documentation for specific instructions.

Network Interface Setup: Ensure your network interface is correctly configured and active. Verify the interface name (e.g., eth0, enp0s3) and ensure it is enabled in your network configuration.

Installation Process

With the prerequisites and pre-installation tasks completed, you can proceed with the Pi-Hole installation. This section details the basic and alternative installation methods.

Basic Installation Method

Command Line Installation: The easiest way to install Pi-Hole is via the command line. This method downloads and executes the official Pi-Hole installation script.

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

Special Considerations for Ubuntu 24.04: As Ubuntu 24.04 LTS is relatively new, the Pi-Hole installer might display an “Unsupported OS” message. To bypass this, use the PIHOLE_SKIP_OS_CHECK parameter.

curl -sSL https://install.pi-hole.net | PIHOLE_SKIP_OS_CHECK=true sudo -E bash

OS Check Bypass Procedure: The PIHOLE_SKIP_OS_CHECK=true command-line parameter instructs the installer to skip the OS check, allowing the installation to proceed on Ubuntu 24.04 LTS. The sudo -E part ensures that the environment variables are passed to the sudo command.

Alternative Installation Methods

Git Clone Method: For users who prefer to review the code before execution, the Git clone method offers a secure alternative. Clone the Pi-Hole repository using Git.

git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
cd "Pi-hole/automated install/"
sudo bash basic-install.sh

Manual Download Method: Another option is to manually download the installation script and execute it. This method provides full transparency over the installation process.

wget -O basic-install.sh https://install.pi-hole.net
sudo bash basic-install.sh

Docker Deployment Option: For users familiar with containerization, Docker provides a convenient way to deploy Pi-Hole. Refer to the official Pi-Hole Docker repository for detailed instructions.

Configuration Steps

Following the installation, configure Pi-Hole to suit your network and preferences. This section covers the initial setup and security settings.

Initial Setup

DNS Provider Selection: During the installation, you’ll be prompted to select a DNS provider. Choose a reliable and fast DNS server such as Google DNS (8.8.8.8, 8.8.4.4), Cloudflare (1.1.1.1, 1.0.0.1), or OpenDNS.

Interface Configuration: Select the network interface that Pi-Hole should listen on. Typically, this is the primary network interface connected to your LAN (e.g., eth0.

Web Admin Setup: Enable the web admin interface to manage and monitor your Pi-Hole server. This interface provides access to statistics, settings, and configuration options.

Security Settings

Privacy Mode Selection: Choose a privacy mode for FTL (Faster Than Light) DNS. This setting determines the level of detail logged by Pi-Hole. Options range from logging everything to logging only essential data.

Query Logging Options: Enable query logging to track DNS queries and identify potential issues. Be mindful of the privacy implications and ensure compliance with local regulations.

Password Management: Set a strong password for the web admin interface to prevent unauthorized access. Use the following command to set or change the password:

pihole -a -p

Post-Installation Tasks

After completing the installation and initial configuration, perform these post-installation tasks to ensure Pi-Hole is functioning correctly and integrated into your network.

Verification Steps

Service Status Check: Verify that the Pi-Hole service is running using the following command:

sudo systemctl status pihole-FTL.service

Web Interface Access: Access the Pi-Hole web interface by navigating to http://[your_pihole_ip]/admin in your web browser. Log in using the password set during the configuration.

Install Pi-Hole on Ubuntu 24.04 LTS

DNS Functionality Testing: Test DNS functionality by flushing your DNS cache and browsing the internet. You should notice a significant reduction in ads.

Network Configuration

Client Device Setup: Configure your client devices to use Pi-Hole as their DNS server. This can be done manually on each device or by configuring your router to distribute the Pi-Hole DNS server via DHCP.

DHCP Settings: If your router supports it, configure the DHCP settings to distribute the Pi-Hole’s IP address as the primary DNS server. This ensures that all devices connecting to your network automatically use Pi-Hole for ad blocking.

DNS Resolver Configuration: Ensure that the DNS resolver on your Ubuntu server is correctly configured to use Pi-Hole. Edit the /etc/resolv.conf file to include nameserver 127.0.0.1 (or the static IP of your Pi-Hole server).

Advanced Configuration

To further optimize your Pi-Hole setup, consider these advanced configuration options.

Performance Optimization

Cache Settings: Adjust the cache settings in the Pi-Hole web interface to improve DNS resolution speed. Experiment with different cache sizes to find the optimal configuration for your network.

Memory Allocation: Monitor the memory usage of the Pi-Hole process and adjust the allocated memory as needed. Insufficient memory can lead to performance issues.

Query Handling: Configure the query handling settings to optimize DNS query processing. This includes setting limits on concurrent queries and adjusting the query timeout values.

Security Hardening

SSL Certificate Setup: Secure the web admin interface with an SSL certificate to encrypt communication between your browser and the Pi-Hole server. This prevents eavesdropping and protects your login credentials.

Access Control: Implement access control measures to restrict access to the Pi-Hole web interface. This can include IP address whitelisting and user authentication.

Firewall Configuration: Configure your firewall to allow only necessary traffic to the Pi-Hole server. This reduces the attack surface and enhances overall security.

Troubleshooting Guide

Even with careful setup, issues can arise. Here are some common problems and solutions.

Common Installation Issues: If you encounter installation errors, double-check that you’ve met all the prerequisites and followed the instructions correctly. Use the PIHOLE_SKIP_OS_CHECK=true parameter if necessary.

Network Connectivity Problems: If you experience network connectivity problems, verify that your static IP address is correctly configured and that your DNS settings are pointing to the Pi-Hole server.

Web Interface Access Issues: If you can’t access the web interface, ensure that the Pi-Hole service is running and that your firewall is not blocking access to port 80 or 443.

Congratulations! You have successfully installed Pi-Hole. Thanks for using this tutorial for installing the Pi-Hole open-source DNS on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Pi-Holes website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button