1. Overview
Pi-hole is a network-level ad blocker and internet tracker blocking application that acts as a DNS sinkhole. It also can function as a DHCP server and DNS filter. Besides that, it can also speed up your network since advertisements are blocked before they are downloaded and DNS requests are cached. The most awesome part is that it works networkwide and you don’t have to install browser plugins or applications on each device. In this tutorial, we’re going to install and setup Pi-hole on ubuntu 20.04. These same steps can also be applied for the installation and setup Pi-hole on Centos, Debian, Fedora, and Raspbian.
2. Clone repository and run
We can get the latest release of the Pi-hole from it’s Github repo. Let’s clone the repo from github.com. Run the following command in your terminal to clone the Pi-hole repo.
git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
If you get git not found error as shown, please install the git by running the command below and clone the repository as shown above.
unixbin@pi-hole:~$ git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole Command 'git' not found, but can be installed with: apt install git Please ask your administrator. unixbin@pi-hole:~$
sudo apt install -y git
Once you have cloned the repository, run the installation script by executing following command.
cd "Pi-hole/automated install/"
sudo bash basic-install.sh
After the setup check’s for requirements if all requirements are satisfied. It will present you with the following welcome screen. Press enter to proceed.
Next, you will be presented with the donation screen. If you love Pi-hole please consider making a donation. Press enter to proceed.
Next, you’ll be presented with the network setup page as shown, please press enter to proceed.
3. Select DNS provider
Next, you’ll be presented with a prompt to select an upstream DNS provider. I suggest you select either Google or Cloudflare as they have the most robust DNS infrastructure. You can also select other DNS providers if you wish. You can move between the DNS provider by up and down keys. Once you select your preferred DNS provider press the enter key to proceed.
4. select adblock list
Select the filter list for add blocking. You can unselect the list by pressing the space key when the list is selected. press the tab and enter key to proceed.
5. Select protocol
Select whether to use IPv4 or Ipv6 or both. It’s generally good to leave both selected. press the tab and enter key to proceed.
6. Static ip address
Ensure that you would like to use the given IP address as the static/reserved IP address for the host running Pi-hole. If not select no by pressing tab and hit enter to input the desired IP address.
7. web admin interface
Select if you wish to install a web admin interface. It’s better to leave it as default. Press the enter key to proceed.
8. Install lighttpd
Select if you wish to install a webserver. This will install Lighttpd to serve the web admin interface. It’s better to leave it as the default unless you would like to install Apache or Nginx which is overkill just to run a web admin interface. Press enter to proceed.
9. log queries
We sure’ly want to see the log’s of all the DNS hit’s show leave default and press enter to proceed.
10. Select privacy mode
In this prompt select whether you would like to show everything on the log or anonymize log entry’s on the Pi-hole. It’s also better to leave the default as we can change later from GUI if you change your mind about the selected option. Press enter and wait for the installation to complete.
11. Acess web admin
Once the setup is completed, the screen shows the URL to access web admin and the credentials.copy and paste the URL in the browser and enter the credentials to access web admin.
12. Set pi-hole as DNS server
Now login to your router and set the DNS the IP of the pi-hole server. If you cannot access your router or if your router is managed. You can also manually set the DNS server. To manually set the DNS server in ubuntu 20.04 goto settings select wifi and open the wifi you’re connected to. Once the wifi connection window is open select IPv4. In the IPv4 Method field select manual and enter the IP address, Netmask, and Gateway information. In DNS filed turn off the automatic DNS and enter the IP of the pi-hole server. Once all changes are made apply the settings. I have been using this for a day and it has already blocked 14.9% of DNS queries that’s a lot of ads blocked.
13. Conclusion
You have successfully installed pi-hole on ubuntu 20.04. Now your network will be noticeably faster and also annoying adds will be gone. Please let us know in the comment show the installation went for you.