How to Install Pi-hole on AlmaLinux 9

pi-hole installation Debian

Pi-hole is a powerful, network-wide ad blocker that can be installed on your network to block ads, trackers, and other unwanted content. This guide will walk you through the step-by-step process of installing Pi-hole on AlmaLinux 9.

Prerequisites

Before you begin, ensure you have the following:

  • A system running AlmaLinux 9.
  • Root or sudo access to the system.
  • Basic knowledge of the terminal.

Step 1: Update Your System

First, update your AlmaLinux system to ensure all packages are up-to-date.

sudo dnf update -y

Step 2: Install Necessary Dependencies

Install dependencies required for Pi-hole to run smoothly.

sudo dnf install -y epel-release
sudo dnf install -y curl git iproute bind-utils

Step 3: Configure Your Network

Pi-hole needs a static IP address to function correctly. Edit your network configuration file to set a static IP address. This example assumes you are using a typical ifcfg file for network configuration.

  1. Find your network interface name:
   ip a

Let’s assume the interface name is eth0.

  1. Edit the network configuration file:
   sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
  1. Add or modify the following lines to set a static IP address:
   BOOTPROTO=none
   IPADDR=192.168.1.2
   NETMASK=255.255.255.0
   GATEWAY=192.168.1.1
   DNS1=192.168.1.1

Replace the IP addresses with appropriate values for your network.

  1. Restart the network service to apply changes:
   sudo systemctl restart network

Step 4: Download and Run the Pi-hole Installer

Download the Pi-hole installation script using curl and then run it.

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

Step 5: Configure Pi-hole

The installation script will guide you through the configuration process. Here are the key steps:

  1. Select Upstream DNS Provider: Choose a DNS provider. Common options include Google, OpenDNS, and Cloudflare.
  2. Blocklists: Pi-hole will provide a default blocklist. You can add more lists later if needed.
  3. Network Interface: Choose the network interface (e.g., eth0) that Pi-hole will use.
  4. IP Address Settings: Ensure the IP address matches the static IP you set earlier.
  5. Web Admin Interface: Enable the web admin interface and log queries if you want to monitor and manage Pi-hole via a web browser.
  6. Install web server (Lighttpd): Choose to install the web server component if you want to use the web admin interface.
  7. Privacy Mode: Select the level of privacy for statistics logging.

Step 6: Completing the Installation

Once the configuration is complete, Pi-hole will finalize the installation. You’ll be provided with an admin password for the web interface. Make sure to write this down.

Step 7: Access the Pi-hole Web Interface

Open a web browser and navigate to http://<your_static_IP>/admin. Log in using the admin password provided during the installation.

Step 8: Configure Your Router

To use Pi-hole as your DNS server, you need to configure your router to point to the Pi-hole’s IP address. This process varies by router model, but generally involves:

  1. Logging into your router’s admin interface.
  2. Finding the DNS settings.
  3. Setting the primary DNS server to the IP address of your Pi-hole.

Step 9: Test Your Setup

Finally, test your setup to ensure Pi-hole is blocking ads. You can visit a website known for ads, or use Pi-hole’s web interface to check query logs and statistics.

Step 10: (Optional) Update Pi-hole

To keep Pi-hole updated, use the following commands:

pihole -up

Conclusion

By following these steps, you have successfully installed Pi-hole on AlmaLinux 9. Enjoy a cleaner, ad-free browsing experience across your entire network. For further customization and management, explore Pi-hole’s web interface and documentation.