How to Install Pi-Hole on Ubuntu (Beginner’s Guide)


Ads are all over the place on the Internet. You develop a sixth sense to ignore them, use a browser extension like AdBlock to hide some of them, or be the extreme guy and block everything on your whole network, by installing Pi-Hole on Ubuntu. How do you do this? I will explain my setup in this article.

Pi-Hole is a free and open-source ad blocker that can be installed on any Linux distribution with only one command line: “curl -sSL https://install.pi-hole.net | bash”. Once done, the network configuration needs to be updated to use it as the main DNS server.

This might seem simple at first glance, but I bet you’ll need more details on how to do this safely and efficiently. Keep reading to see how to set up Pi-Hole step-by-step on your network.

Pi-Hole server Installation on Ubuntu


If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!

Pi-Hole requirements

Pi-Hole is a lightweight solution, and that doesn’t require much processing power to install it. In fact, it’s mainly used on the Raspberry Pi, a tiny computer with limited CPU and RAM, so it shouldn’t be an issue on any standard computer.

In their documentation, Pi-Hole recommends at least 2 GB free space on the disk and 512 MB RAM.

Your computer will be perfect, but you can also use a Raspberry Pi 4 or a minimal Intel NUC for example. I just read that you can even install it on a Synology NAS, with a docker container (I have this one on Amazon, but you can find cheaper models).

Warning: Pi-Hole may not be supported on the latest Ubuntu release, check this link to verify.

You can install Pi-Hole directly on your computer if you are using Ubuntu, but it’s probably better to install it on something you’ll run 24/7. For example, if you configure the whole network to use Pi-Hole, Internet won’t work on other devices if your computer is off or in sleeping mode. This would not be a great experience :).
That’s why I suggest using a Raspberry Pi (you can install Ubuntu on it), a NAS or any device that you can leave running all the time.

Note: If you are trying this on a Raspberry Pi with the default operating system, I have a detailed tutorial on how to install Pi-Hole on Raspberry Pi. In this article, I’ll focus on Ubuntu.

Raspberry Pi Bootcamp
Sale: 10% off today.
Take it to the next level.
I'm here to help you get started on Raspberry Pi.
Learn all the skills you need in the correct order.

Update your operating system

Once your hardware is selected and Ubuntu is installed, the first thing to do is to update your system. It’s a good practice to follow before installing anything on your system, just to avoid dependency issues and version incompatibility.

You can do this easily in a terminal:
sudo apt update
sudo apt upgrade

Or use the software updater tool in the graphic interface if you are using the Desktop version:

Click on “Install now” and type the user password to confirm the installation.
A reboot is probably a good idea if you have many updates to catch up on.

Then you’ll also need to install curl on your system if not already there:
sudo apt install curl

The Pi-Hole script will install anything else after that.

Pi-Hole installation script

Once your system is ready, the installation can be done with only one command, by copying and pasting this in a terminal:
curl -sSL https://install.pi-hole.net | bash

The process is almost automatic, but you still need to answer a few questions to adjust your settings:

  • Type your user password, and the installation starts:
  • A few seconds later, a wizard will shows up with a few questions for you to answer:

    Just confirm by pressing Enter for the first few questions.
  • Then choose your DNS provider:

    Google is fine, but you can choose another one if you prefer.
  • Pi-hole relies on third-party lists to block ads. By default, it will use StevenBlack’s hosts list, but you can deselect it if you want (not recommended).
    Press Enter to continue (and the space bar to select / deselect).
  • Then, select the protocols you want to use (I recommend keeping both).
  • Pi-Hole will use a static IP address (to avoid reconfiguring everything each time it uses a new ip).
    The next step is to configure if you want to keep the current ip or set another one manually.
    It depends on your network, at home you can probably keep the default one without any major issues.
  • Then confirm to enable the web interface and the web server (highly recommended):
  • A couple of questions later, the installation wizard will configure everything as requested.

Make sure to not use the default password and move to the next step.

Configure your clients to use Pi-Hole

Once your server is installed, the next step is to configure your network to use this server. Pi-Hole works like a DNS server, so you need to change the primary DNS server on all of the devices to use the Pi-Hole IP address.

This can be done manually on each device, but the easiest way is to change the default DNS server in your DHCP configuration.

Edit the DHCP configuration to set Pi-Hole as the default DNS

The easiest way to config all devices at once is to go to your DHCP server configuration, and set the primary DNS server to the Pi-Hole server IP address.

If you are installing this at home, your DHCP server is probably your Internet router.
I won’t explain how to do this in detail, as it will be different for each provider and router, but as a whole the idea is to find the DHCP settings on the web interface, and change the DNS server IP address.

By default, it’s probably the DNS server from your provider.
In my case, it was in the DNS settings:

Once you find something like this, remove the default values and set the primary DNS server to your Pi-Hole installation IP address (probably something like 192.168.1.X or 192.168.0.X).
Leave the secondary DNS server empty.

It may take a few hours to update the configuration on all devices on your network, but it will be done automatically.

Change the network configuration on each client to use Pi-Hole

The alternative is to manually update the configuration on each device you want to use with Pi-Hole. This might take more time, especially if you have many devices on your network, but this way you can make sure everything is working before breaking the Internet for the whole family!

On Windows 10:

  • Right-click on the “Start Menu” and choose “Network Connections”.
  • Then click on “Change adapter settings”.
  • Right-click on your current connection and choose “Properties”.
  • Double-click on “Internet Protocol Version 4 (TCP/IPv4)”.
  • Set the DNS server to static and enter your Pi-Hole server IP Address.
    Keep the secondary DNS server empty.

On Linux and Mac OS:

  • If you have a graphical interface, you’ll find the network settings in the System Preferences.
  • If not, you can edit the /etc/resolv.conf file and replace the current DNS server with the Pi-Hole IP address.

On mobile, it’s in your Wi-Fi settings.
Click details or edit network on a network to see the DNS configuration.

Master your Raspberry Pi in 30 days
Sale: 10% off today.
Download the eBook.
Uncover the secrets of the Raspberry Pi in a 30 days challenge.
Learn useful Linux skills and practice multiples projects.

How to know if Pi-Hole is working?

To know if Pi-Hole is working, you can go to the web interface and check if it’s blocking ads. Another way is to try to access a domain hosting ads (like doubleclick.net) and verify that the Pi-Hole page appears instead of the website content.

The web interface is enabled on http://localhost/admin (if installed on your computer) or http://IP_Address/admin (if installed on another computer). The default password is provided at the end of the installation.

Pi-Hole installation guide on Raspberry Pi

Pi-Hole FAQ


Grab your free PDF file with all the commands you need to know on Raspberry Pi!

Can Pi-Hole run on any Linux distribution?

Pi-Hole is officially supported on Raspberry Pi OS (Raspbian), Ubuntu, Debian, Fedora and CentOS. As most Linux distributions are based on them, it should run on almost any of them.

Just check the exact supported release on this page before trying to install it. They are often a little behind when a new version is available. For example, at the time of writing (July 2021, Ubuntu 21.04 is not yet supported).
Consider using docker if you experience any compatibility issues with your system.

What can Pi-Hole be installed on?

The prerequisites to install Pi-Hole are 2 GB of disk space and 512 MB of RAM, so it can run on almost any computer, even the older ones. Raspberry Pi and other single board computers are also supported as long as a supported operating system is installed.

My recommendation is to use a Raspberry Pi (as it’s the cheapest option), plug it somewhere on your network and keep it on all the time.

What can I do with Pi-Hole?

The main purpose of Pi-Hole is to block ads on the Internet, by blocking their servers at a network level. Pi-Hole can also be used as a DHCP server and a network monitor.

Master Python on Raspberry Pi
Sale: 10% off today.
Get the eBook.
Do more with your Raspberry Pi, learn the useful concepts and take the shortcuts.
You miss half of the fun of using a Raspberry Pi if you don’t know anything about Python.

Does Pi-Hole stop YouTube ads?

As Pi-Hole is working at a network level, it’s not the best option to block YouTube ads. On YouTube, ads and videos are served from the same domain, so Pi-Hole will block both or none, it can’t analyze the exact content.

If blocking YouTube ads is your main goal, a browser extension like AdBlock has better chances of success.

Does Pi-Hole stop malware and phishing?

Pi-Hole won’t natively stop malware and phishing on your devices, but you can add additional block lists with domains that are known to host malware or act as phishing. It won’t have a 100% success rate, but it might increase the overall security on your network.

If you have any comment, suggestion or just want to chat with us about this tutorial,
you can post your messages in the community on Patreon. See you there!

Raspberry Pi Resources

Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now

Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiples projects with step-by-step guides.
Download the e-book

VIP Community
If you just want to hang out with me and show your support, you can also join the Patreon community. I share behind-the-scenes content there and give you early access to my content. You’ll also get a shoutout when you join.
More details here

Need help to build something with Python?
Create, understand and improve any Python script for your Raspberry Pi.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now

You can also find all my recommendations for tools and hardware on this page.


This tutorial doesn't work anymore? Report the issue here, so that I can update it!


Patrick Fromaget

I'm the lead author and owner of RaspberryTips.com. My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

Recent Posts

Master your Raspberry Pi - 10% off