Pi-hole is a tremendously powerful DNS ad blocker that can protect your network from ads, telemetry data, and many other types of undesirable traffic. Updating your Pi-hole environment is a great way to ensure you are fully protected.
This guide will look at how to update pihole and see what steps are required to ensure your Pi-hole environment is properly running the latest version of Pi-hole core files.
Table of Contents
What is Pi-hole?
Pi-hole is a powerful DNS-based ad blocker on a Raspberry Pi or any other Linux-based system that serves as DNS root data for devices on your network and installing blocking for unwanted traffic.
Pi-hole blocks ads for all devices connected to your network, including smartphones, tablets, smart TVs, and gaming consoles. However, to ensure you are fully protected, it must be updated to the latest version to keep Pi-hole running smoothly.
Checking the current Pi-hole version
Before looking at the Pi-hole update, you will want to check the current version of the Pi-hole software running on your system. You can do this by logging into the Pi-hole web interface and checking the version number at the bottom of the page.
You can also check the version number from the command line by running the following command:
pihole -v
This command will display the current Pi-hole version and the latest version of Pi-hole. You can also see the version of Pi-hole from Pi-hole’s web GUI. Effective Pi-hole blocking depends on having the latest Pi-hole, AdminLTE version, and current FTL version.
How to update Pihole?
Once you know your current Pi-hole version, you can check for available updates. One of the benefits to running Pi-hole in your Linux environment is using the same update mechanism as other Linux-based systems. You can update Pi-hole and other system components like php version and others by running the following commands:
sudo apt-get update sudo apt-get upgrade
These commands will update all the packages on your system, including Pi-hole.
Below the updates are applying normal system updates for PHP, upgraded packages, etc.
Automatic update
By default, Pi-hole is set up to update itself automatically when a new version is available. However, you may want to check if automatic updates are enabled as shown. This command will check for available updates and prompt you to install them to update Pi-hole easily. If updates are available, you can follow the on-screen instructions to complete the update. It will also run through some prerequisite checks, including:
- root user check
- FTL version
- disk space check
- existing PHP installation detected check
- existing FTL binary
- It will wait for the lighttpd service to start
All findings will be updated in the install log.
You can do this by running the following command to initiate the Pi-hole update process:
pihole -up
This command will check for available updates for the installed Pi-hole and enable automatic updates if they are not already enabled.
You will see the workflow of the update includes installer dependency checks:
- Update local cache of available packages
- Existing php installation detected
- Check for existing repository
- Checking for git
- Checking for iproute2
- Checking for dialog
- Pi-hole core files out of date
- Root user check
- Supported OS detected
- Update repo in var www html admin
- Deleting existing list cache
- installing latest cron script
- date updating local repo
- installing latest logrotate script
- Pi-hole’s admin interface is out of date and updating
- man pages installed
- Installation detected php version
- restarting pihole ftl service
- installing sudoer file
- performing unattended setup
- enabling pihole ftl service
- installing scripts
- restarting lighttpd service
- enabling lighttpd service
- installing configs
Status retrieval successful for blocklists
You should see on your blocklists updates, the message:
- status retrieval successful as each are updated
Troubleshooting
Let’s consider a few things you can do to troubleshoot your Pi-hole installation.
First, ensure you have enough disk space for the update. You can check your disk space by running the following command in Linux:
df -h
Once you check your disk usage, you can proceed with the Pi-hole update.
If you’re having trouble with Pi-hole after the update, you can try restarting the Pi-hole FTL service by running the following command:
sudo service pihole-FTL restart
The Pi-hole FTL service handles DNS queries and blocks ads and is a vital core service you need to check if things are not working correctly with Pi-hole.
You can also do this in the web interface under System > DNS > Restart DNS service:
If all else fails, you can try uninstalling and reinstalling Pi-hole. You can do this by running the following commands:
pihole uninstall curl -sSL https://install.pi-hole.net | bash
These commands will uninstall Pi-hole and then reinstall it using the latest version.
Pi-hole Docker — Checking for a new image
If you’re using Pi-hole in a Docker container to block ads, you can check if a newer version of the Pi-hole image is available using native Docker commands, such as the docker pull command:
docker pull pihole/pihole
This command will check for the latest Pi-hole image and download it if available. So there isn’t really anything to install or update new Docker image file.
Stop and Remove the Container
First, stop and remove the existing container. You will want to ensure your existing Pi-hole is using a persistent volume mount so your settings are persistent. When you pull the new container, it simply uses the configuration data of the persistent volume.
You can do this by running the following command:
docker stop pihole docker rm pihole
These commands will stop and remove the existing Pi-hole container.
Create a New Container
Once you’ve removed the old container, you can create a new container with the updated image by running the following command:
docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 80:80 -p 443:443 -e TZ=<timezone> -v /etc/pihole/:/etc/pihole/ -v /etc/dnsmasq.d/:/etc/dnsmasq.d/ --dns=127.0.0.1 --dns=1.1.1.1 pihole/pihole
Replace <timezone> with your local timezone, such as “America/Chicago”. This command will create a new Pi-hole container with the updated image and mount the necessary configuration files.
Remove Old Image(s)
For housekeeping on old image(s), you can get rid of these with a Docker command to save disk space. You can do this by running the following command:
docker image prune
It removes any unused images from your system.
Automate Pi-hole Update with Cron Job
To automate Pi-hole updates, you can set up a Linux cron job to check for updates. With the cron job, you can spin up a new container with the updated image. To do this, create a new file in /etc/cron.daily/ with the following content:
#!/bin/sh docker pull pihole/pihole docker stop pihole docker rm pihole docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 80:80 -p 443:443 -e TZ=<timezone> -v /etc/pihole/:/etc/pihole/ -v /etc/dnsmasq.d/:/etc/dnsmasq.d/ --dns=127.0.0.1 --dns=1.1.1.1 pihole/pihole docker image prune
Replace <timezone> with your local timezone, such as “America/Chicago”. If available, this cron job will check for updates daily and create a new container with the updated image.
Watchtower
You can also use a solution called Watchtower to update your Pi-hole container. Watchtower is a Docker container solution that “watches” the containers you have running on your Docker host and, at a configured interval, goes out and automatically pulls the newest container image for your Docker containers running, including Pi-hole.
This way, you don’t have to create a corn job or manually configured scripts to pull down the latest Pi-hole container. Instead, Watchtower automatically performs the heavy lifting for you, so you are always running the latest containers.
You can take a look at Watchtower here for updating your Docker containers.
Wrapping up
Updating Pi-hole is essential to keep your ad-blocking software running smoothly. Whether you update manually or with a cron job, staying up-to-date with the latest Pi-hole version is important.
You can easily update Pi-hole and keep your network free of ads using manual updates, system updates, a cron job, or using Watchtower. With these tools, you can ensure that your Pi-hole installation is always up-to-date and running smoothly.