Home / Projects / Pi-hole for the whole network

Pi-hole for the whole network

5 January 2020Rafael44p

Pi-Hole who hasn't heard of it?

You might have heard it first coming from LinusTechTips or searched a way to block advertisements on your home network. In my case I wanted to block advertisements and certain bad websites that contain trojans and viruses, so this way I can keep my network a little safer while having less advertisements on forums, blogs and what not.

How does Pi-Hole work? It's a DNS server which associates various information with domain names and filters out ads before they are reaching your device, so basically an intermediary between your preferred DNS (in my case everything goes to Cloudflare) and your whole network if you configure it that way.

Pi-Hole dashboard showing blocked domains and hourly speedtest history

Some things Pi-Hole offers:

  • Network-wide protection.
  • Block in-app advertisements.
  • Improve network performance.
  • Monitor statistics.
  • VPN possibility.
  • Automatic speedtests every hour.

As you can see my internet connection is not the most stable and Pi-Hole knows about it. You can easily add blocklists or add websites to whitelists, I have quite some domains in my blocklist as you may have noticed.

Installation on Ubuntu

Pi-Hole running on an Ubuntu server

The best way and the way I did it is to install Pi-Hole on an Ubuntu server I already had running. Here is a mini guide.

  • git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
  • cd "Pi-hole/automated install/"
  • sudo bash basic-install.sh

And follow anything that pops up, don't forget to note the password, you can change it later (pihole -a -p to reset the password). After that, access Pi-Hole through http://pi.hole/admin/. If for some strange reason that doesn't work, type in the machine's ip address like this http://IP_ADDRESS_OF_YOUR_PI_HOLE/admin/ and we can now access Pi-Hole.

Speedtest on Pi-Hole

To install the Speedtest add-on to pi-hole is a little tricky, first we need to install speedtest cli:

  • curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash
  • sudo apt-get install speedtest

Now we can verify that it's working by typing speedtest in terminal. After getting the speedtest results we can install this module into pi-hole.

Backup original admin folder just in case.

  • sudo su
  • cd /var/www/html
  • mv admin org_admin
  • git clone https://github.com/arevindh/AdminLTE admin

Get latest webscripts file.

  • cd /opt/pihole/
  • mv webpage.sh webpage.sh.org
  • wget https://github.com/arevindh/pi-hole/raw/master/advanced/Scripts/webpage.sh

Copy Databasefile.

  • cp /var/www/html/admin/scripts/pi-hole/speedtest/speedtest.db /etc/pihole/

Now go to the settings page in pi-hole and set the speedtest schedule and display range, tick Flush speedtest history (for the first time only) and set speedtest mode to Official CLI.

Don't forget to add some blocklists, it comes with a standard list which blocks some things not everything. Also re-route your router's primary DNS to Pi-Hole, else it won't do anything. Enjoy Pi-Hole.

« Xigmanas on an old laptop Small wind turbine test »