Installing and configuring Pi-hole is a straightforward process that involves setting up a Raspberry Pi (or another compatible system) and configuring it to block ads at the network level.
Here's a basic tutorial:
What is Pi-hole?
Pi-hole is a network-wide ad blocker that filters unwanted content at the DNS level, providing a cleaner browsing experience for all devices connected to your network.
Lets look at some of the features as per the PI-hole website
Network-wide protection
Instead of browser plugins or other software on each computer, install Pi-hole in one place and your entire network is protected.
Block in-app advertisements
Network-level blocking allows you to block ads in non-traditional places such as mobile apps and smart TVs, regardless of hardware or OS.
Improve network performance
Since advertisements are blocked before they are downloaded, network performance is improved and will feel faster.
Monitor statistics
Our Web interface offers control of your Pi-hole and a central place to view statistics. We also include an API for extending these stats.
Step 1: Prepare Your Raspberry Pi
Requirements:
- A Raspberry Pi (Pi-hole works with most models, including Pi 2, 3, 4, or Zero W).
- MicroSD card (8GB or larger) with Raspberry Pi OS installed.
- Power supply and network connection (Ethernet recommended for stability).
- Basic knowledge of SSH or physical access to the Pi.
Install Raspberry Pi OS:
- Download and install Raspberry Pi Imager.
- Insert the microSD card into your computer.
- Use the imager to install Raspberry Pi OS (Lite version is sufficient) on the microSD card.
- Enable SSH by adding an empty file named ssh (no file extension) to the root of the microSD card's boot directory.
- Insert the microSD card into the Raspberry Pi and power it on.
Access the Pi:
- Determine the IP address of your Raspberry Pi using your router's admin panel or a network scanner like nmap.
- SSH into the Pi using a terminal or an SSH client like PuTTY:
ssh pi@<IP_ADDRESS>
- Default username is pi and password is raspberry (change it immediately with passwd for security).
Step 2: Install Pi-hole
- Update the system:
sudo apt update && sudo apt upgrade -y
- Install Pi-hole using the automated script:
curl -sSL https://install.pi-hole.net | bash
Alternatively, download the script manually:
wget -O basic-install.sh https://install.pi-hole.net sudo bash basic-install.sh
- Follow the installation prompts:
- Choose a static IP address: Assign a static IP to the Pi to ensure consistent DNS routing.
- Select an upstream DNS provider: Options include Google, OpenDNS, Cloudflare, etc.
- Enable or disable query logging: Decide based on your privacy preferences.
- Select a privacy mode: Determines how much query information is logged.
Step 3: Configure Network Settings
Option 1: Configure Devices Manually
Set the DNS server on each device to the IP address of your Raspberry Pi.
Option 2: Configure Router (Recommended)
- Log in to your router's admin panel.
- Set the Pi-hole IP address as the primary DNS server under the DHCP settings.
- Disable any secondary DNS server to ensure all requests pass through Pi-hole.
Option 3: Enable Pi-hole as DHCP Server
If your router doesn't allow DNS customization:
- Access the Pi-hole admin interface.
- Enable the built-in DHCP server in the Settings > DHCP section.
Step 4: Access the Admin Dashboard
- Open a browser and go to http://<Pi-hole_IP_address>/admin.
- Log in using the password displayed at the end of the installation. You can reset it if needed:
pihole -a -p
Step 5: Customize Block Lists
- Add more block lists for enhanced ad blocking:
- Use the Group Management > Adlists section in the admin interface.
- Popular sources: firebog.net.
- Update the gravity list to apply changes:
pihole -g
Step 6: Monitor and Optimize
- Check statistics and logs in the dashboard.
- Whitelist or blacklist domains as needed:
- Whitelist: For legitimate content being blocked.
- Blacklist: To block unwanted domains not caught by default.
Step 7: Regular Maintenance
- Update Pi-hole regularly:
pihole -up
- Keep your Raspberry Pi OS updated:
sudo apt update && sudo apt upgrade -y
Step 8: Advanced Configuration (Optional)
- Integrate with Unbound for a private DNS resolver:
- Install Unbound:
sudo apt install unbound
- Configure Unbound with a recursive DNS resolver:
sudo nano /etc/unbound/unbound.conf.d/pi-hole.conf
Add the recommended configuration from the Pi-hole docs.
- Restart Unbound:
sudo systemctl restart unbound
- Set Pi-hole to use 127.0.0.1#5335 as the upstream DNS server.
- Install Unbound:
- Install a VPN for remote ad blocking:
- Configure OpenVPN or WireGuard on the same Raspberry Pi to protect your network while on the go.
Troubleshooting Tips
- Check Pi-hole Status:
pihole status
- Restart Pi-hole Services:
sudo systemctl restart pihole-FTL
- Check DNS Resolution:
dig pi-hole.net
By following these steps, you should have a fully operational Pi-hole setup providing ad-free browsing across your network. If you encounter issues, consult the Pi-hole community for support.