habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Install Pi-Hole in Ubuntu 20.04

7 min read

Hi Dude. Today i want to share about install pi-hole in ubuntu 20.04 This easy step for beginner user. Pihole is tool open source that main purpose for blocking ads and malware via DNS.

Pi-hole logo

Prerequisites Install Pi-Hole Ubuntu 20.04

Hardware

Pi-hole is very lightweight and does not require much processing power

  • Min. 2GB free space, 4GB recommended
  • 512MB RAM

IP Addressing

Pi-hole needs a static IP address to properly function.

Install With Curl

After prequisition fulfilled, lets install pi-hole with curl.

root@habibza:~# curl -sSL https://install.pi-hole.net | bash


  [✓] Root user check

        .;;,.
        .ccccc:,.
         :cccclll:.      ..,,
          :ccccclll.   ;ooodc
           'ccll:;ll .oooodc
             .;cll.;;looo:.
                 .. ','.
                .',,,,,,'.
              .',,,,,,,,,,.
            .',,,,,,,,,,,,....
          ....''',,,,,,,'.......
        .........  ....  .........
        ..........      ..........
        ..........      ..........
        .........  ....  .........
          ........,,,,,,,'......
            ....',,,,,,,,,,,,.
               .',,,,,,,,,'.
                .',,,,,,'.
                  ..'''.

  [i] SELinux not detected
  [✓] Update local cache of available packages

  [✓] Checking apt-get for upgraded packages... 1 updates available
  [i] It is recommended to update your OS after installing the Pi-hole!

  [i] Checking for / installing Required dependencies for OS Check...
  [✓] Checking for grep
  [i] Checking for dnsutils (will be installed)
  [i] Waiting for package manager to finish (up to 30 seconds)
  [i] Processing apt-get install(s) for: dnsutils, please wait...

Selecting previously unselected package dnsutils.
(Reading database ... 108510 files and directories currently installed.)
Preparing to unpack .../dnsutils_1%3a9.16.1-0ubuntu2.10_all.deb ...
Unpacking dnsutils (1:9.16.1-0ubuntu2.10) ...
Setting up dnsutils (1:9.16.1-0ubuntu2.10) ...

  [✓] Supported OS detected
  [i] Checking for / installing Required dependencies for this install script...
  [✓] Checking for git
  [✓] Checking for iproute2
  [i] Checking for dialog (will be installed)
  [✓] Checking for ca-certificates
  [i] Waiting for package manager to finish (up to 30 seconds)
  [i] Processing apt-get install(s) for: dialog, please wait...

Selecting previously unselected package dialog.
(Reading database ... 108514 files and directories currently installed.)
Preparing to unpack .../dialog_1.3-20190808-1_amd64.deb ...
Unpacking dialog (1.3-20190808-1) ...
Setting up dialog (1.3-20190808-1) ...
Processing triggers for man-db (2.9.1-1) ...

  [i] IPv4 address: 10.12.12.128/24
  [i] Unable to find IPv6 ULA/GUA address
  [i] IPv6 address:
  [i] Using upstream DNS: Google (ECS, DNSSEC) (8.8.8.8, 8.8.4.4)
  [i] Installing StevenBlack's Unified Hosts List
  [i] Installing Admin Web Interface
  [i] Installing lighttpd
  [i] Query Logging on.
  [i] Using privacy level: 0
  [✗] Check for existing repository in /etc/.pihole
  [i] Clone https://github.com/pi-hole/pi-hole.git into /etc/.pihole...HEAD is now at aefbe1f Merge pull request #4812 from pi-hole/development
  [✓] Clone https://github.com/pi-hole/pi-hole.git into /etc/.pihole

  [✗] Check for existing repository in /var/www/html/admin
  [i] Clone https://github.com/pi-hole/AdminLTE.git into /var/www/html/admin...HEAD is now at 1714b08 Merge pull request #2248 from pi-hole/devel
  [✓] Clone https://github.com/pi-hole/AdminLTE.git into /var/www/html/admin

  [i] Checking for / installing Required dependencies for Pi-hole software...
  [✓] Checking for cron
  [✓] Checking for curl
  [✓] Checking for iputils-ping
  [✓] Checking for psmisc
  [✓] Checking for sudo
  [i] Checking for unzip (will be installed)
  [i] Checking for idn2 (will be installed)
  [✓] Checking for libcap2-bin
  [i] Checking for dns-root-data (will be installed)
  [✓] Checking for libcap2
  [✓] Checking for netcat-openbsd
  [✓] Checking for procps
  [i] Checking for lighttpd (will be installed)
  [i] Checking for php-common (will be installed)
  [i] Checking for php-cgi (will be installed)
  [i] Checking for php-sqlite3 (will be installed)
  [i] Checking for php-xml (will be installed)
  [i] Checking for php-intl (will be installed)
  [i] Checking for php-json (will be installed)
  [i] Waiting for package manager to finish (up to 30 seconds)
  [i] Processing apt-get install(s) for: unzip idn2 dns-root-data lighttpd php-common php-cgi php-sqlite3 php-xml php-intl php-json, please wait...

Selecting previously unselected package dns-root-data.
(Reading database ... 108668 files and directories currently installed.)
Preparing to unpack .../00-dns-root-data_2019052802_all.deb ...
Unpacking dns-root-data (2019052802) ...
Selecting previously unselected package libgamin0.
Preparing to unpack .../01-libgamin0_0.1.10-6_amd64.deb ...
Unpacking libgamin0 (0.1.10-6) ...
Selecting previously unselected package gamin.
Preparing to unpack .../02-gamin_0.1.10-6_amd64.deb ...
Unpacking gamin (0.1.10-6) ...
Selecting previously unselected package lighttpd.
Preparing to unpack .../03-lighttpd_1.4.55-1ubuntu1.20.04.1_amd64.deb ...
Unpacking lighttpd (1.4.55-1ubuntu1.20.04.1) ...
Selecting previously unselected package php-common.
Preparing to unpack .../04-php-common_2%3a75_all.deb ...
Unpacking php-common (2:75) ...
Selecting previously unselected package php7.4-common.
Preparing to unpack .../05-php7.4-common_7.4.3-4ubuntu2.12_amd64.deb ...
Unpacking php7.4-common (7.4.3-4ubuntu2.12) ...
Selecting previously unselected package php7.4-json.
Preparing to unpack .../06-php7.4-json_7.4.3-4ubuntu2.12_amd64.deb ...
Unpacking php7.4-json (7.4.3-4ubuntu2.12) ...
Selecting previously unselected package php7.4-opcache.
Preparing to unpack .../07-php7.4-opcache_7.4.3-4ubuntu2.12_amd64.deb ...
Unpacking php7.4-opcache (7.4.3-4ubuntu2.12) ...
Selecting previously unselected package php7.4-readline.
Preparing to unpack .../08-php7.4-readline_7.4.3-4ubuntu2.12_amd64.deb ...
Unpacking php7.4-readline (7.4.3-4ubuntu2.12) ...
Selecting previously unselected package php7.4-cli.
Preparing to unpack .../09-php7.4-cli_7.4.3-4ubuntu2.12_amd64.deb ...
Unpacking php7.4-cli (7.4.3-4ubuntu2.12) ...
Selecting previously unselected package php7.4-cgi.
Preparing to unpack .../10-php7.4-cgi_7.4.3-4ubuntu2.12_amd64.deb ...
Unpacking php7.4-cgi (7.4.3-4ubuntu2.12) ...
Selecting previously unselected package php-cgi.
Preparing to unpack .../11-php-cgi_2%3a7.4+75_all.deb ...
Unpacking php-cgi (2:7.4+75) ...
Selecting previously unselected package php7.4-intl.
Preparing to unpack .../12-php7.4-intl_7.4.3-4ubuntu2.12_amd64.deb ...
Unpacking php7.4-intl (7.4.3-4ubuntu2.12) ...
Selecting previously unselected package php-intl.
Preparing to unpack .../13-php-intl_2%3a7.4+75_all.deb ...
Unpacking php-intl (2:7.4+75) ...
Selecting previously unselected package php-json.
Preparing to unpack .../14-php-json_2%3a7.4+75_all.deb ...
Unpacking php-json (2:7.4+75) ...
Selecting previously unselected package php7.4-sqlite3.
Preparing to unpack .../15-php7.4-sqlite3_7.4.3-4ubuntu2.12_amd64.deb ...
Unpacking php7.4-sqlite3 (7.4.3-4ubuntu2.12) ...
Selecting previously unselected package php-sqlite3.
Preparing to unpack .../16-php-sqlite3_2%3a7.4+75_all.deb ...
Unpacking php-sqlite3 (2:7.4+75) ...
Selecting previously unselected package php7.4-xml.
Preparing to unpack .../17-php7.4-xml_7.4.3-4ubuntu2.12_amd64.deb ...
Unpacking php7.4-xml (7.4.3-4ubuntu2.12) ...
Selecting previously unselected package php-xml.
Preparing to unpack .../18-php-xml_2%3a7.4+75_all.deb ...
Unpacking php-xml (2:7.4+75) ...
Selecting previously unselected package unzip.
Preparing to unpack .../19-unzip_6.0-25ubuntu1_amd64.deb ...
Unpacking unzip (6.0-25ubuntu1) ...
Selecting previously unselected package idn2.
Preparing to unpack .../20-idn2_2.2.0-2_amd64.deb ...
Unpacking idn2 (2.2.0-2) ...
Setting up idn2 (2.2.0-2) ...
Setting up php-common (2:75) ...
Created symlink /etc/systemd/system/timers.target.wants/phpsessionclean.timer → /lib/systemd/system/phpsessionclean.timer.
Setting up php7.4-common (7.4.3-4ubuntu2.12) ...

Creating config file /etc/php/7.4/mods-available/calendar.ini with new version
Creating config file /etc/php/7.4/mods-available/ctype.ini with new version
Creating config file /etc/php/7.4/mods-available/exif.ini with new version
Creating config file /etc/php/7.4/mods-available/fileinfo.ini with new version
Creating config file /etc/php/7.4/mods-available/ffi.ini with new version
Creating config file /etc/php/7.4/mods-available/ftp.ini with new version
Creating config file /etc/php/7.4/mods-available/gettext.ini with new version
Creating config file /etc/php/7.4/mods-available/iconv.ini with new version
Creating config file /etc/php/7.4/mods-available/pdo.ini with new version
Creating config file /etc/php/7.4/mods-available/phar.ini with new version
Creating config file /etc/php/7.4/mods-available/posix.ini with new version
Creating config file /etc/php/7.4/mods-available/shmop.ini with new version
Creating config file /etc/php/7.4/mods-available/sockets.ini with new version
Creating config file /etc/php/7.4/mods-available/sysvmsg.ini with new version
Creating config file /etc/php/7.4/mods-available/sysvsem.ini with new version
Creating config file /etc/php/7.4/mods-available/sysvshm.ini with new version
Creating config file /etc/php/7.4/mods-available/tokenizer.ini with new version
Setting up unzip (6.0-25ubuntu1) ...
Setting up php7.4-readline (7.4.3-4ubuntu2.12) ...
Creating config file /etc/php/7.4/mods-available/readline.ini with new version
Setting up php7.4-intl (7.4.3-4ubuntu2.12) ...
Creating config file /etc/php/7.4/mods-available/intl.ini with new version
Setting up php-intl (2:7.4+75) ...
Setting up dns-root-data (2019052802) ...
Setting up php7.4-opcache (7.4.3-4ubuntu2.12) ...
Creating config file /etc/php/7.4/mods-available/opcache.ini with new version
Setting up php7.4-sqlite3 (7.4.3-4ubuntu2.12) ...
Creating config file /etc/php/7.4/mods-available/sqlite3.ini with new version
Creating config file /etc/php/7.4/mods-available/pdo_sqlite.ini with new version
Setting up php7.4-json (7.4.3-4ubuntu2.12) ...
Creating config file /etc/php/7.4/mods-available/json.ini with new version
Setting up php7.4-xml (7.4.3-4ubuntu2.12) ...
Creating config file /etc/php/7.4/mods-available/dom.ini with new version
Creating config file /etc/php/7.4/mods-available/simplexml.ini with new version
Creating config file /etc/php/7.4/mods-available/xml.ini with new version
Creating config file /etc/php/7.4/mods-available/xmlreader.ini with new version
Creating config file /etc/php/7.4/mods-available/xmlwriter.ini with new version
Creating config file /etc/php/7.4/mods-available/xsl.ini with new version
Setting up php-json (2:7.4+75) ...
Setting up php7.4-cli (7.4.3-4ubuntu2.12) ...
update-alternatives: using /usr/bin/php7.4 to provide /usr/bin/php (php) in auto mode
update-alternatives: using /usr/bin/phar7.4 to provide /usr/bin/phar (phar) in auto mode
update-alternatives: using /usr/bin/phar.phar7.4 to provide /usr/bin/phar.phar (phar.phar) in auto mode

Creating config file /etc/php/7.4/cli/php.ini with new version
Setting up php-sqlite3 (2:7.4+75) ...
Setting up php-xml (2:7.4+75) ...
Setting up php7.4-cgi (7.4.3-4ubuntu2.12) ...
update-alternatives: using /usr/bin/php-cgi7.4 to provide /usr/bin/php-cgi (php-cgi) in auto mode
update-alternatives: using /usr/lib/cgi-bin/php7.4 to provide /usr/lib/cgi-bin/php (php-cgi-bin) in auto mode

Creating config file /etc/php/7.4/cgi/php.ini with new version
Setting up php-cgi (2:7.4+75) ...
Setting up gamin (0.1.10-6) ...
Setting up libgamin0 (0.1.10-6) ...
Setting up lighttpd (1.4.55-1ubuntu1.20.04.1) ...
Enabling unconfigured: ok
Run "service lighttpd force-reload" to enable changes
Created symlink /etc/systemd/system/multi-user.target.wants/lighttpd.service → /lib/systemd/system/lighttpd.service.
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
Processing triggers for ufw (0.36-6ubuntu1) ...
Processing triggers for systemd (245.4-4ubuntu3.17) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for php7.4-cli (7.4.3-4ubuntu2.12) ...
Processing triggers for php7.4-cgi (7.4.3-4ubuntu2.12) ...

  [✓] Enabling lighttpd service to start on reboot...
  [✓] Creating user 'pihole'

  [i] FTL Checks...

  [✓] Detected x86_64 processor
  [i] Checking for existing FTL binary...
  [✓] Downloading and Installing FTL
  [✓] Installing scripts from /etc/.pihole

  [i] Installing configs from /etc/.pihole...
  [✓] No dnsmasq.conf found... restoring default dnsmasq.conf...
  [✓] Installed /etc/dnsmasq.d/01-pihole.conf
  [✓] Installed /etc/dnsmasq.d/06-rfc6761.conf

  [i] Installing blocking page...
  [✓] Creating directory for blocking page, and copying files
  [✓] Backing up index.lighttpd.html

  [✓] Installing sudoer file

  [✓] Installing latest Cron script

  [✓] Installing latest logrotate script
  [i] Backing up /etc/dnsmasq.conf to /etc/dnsmasq.conf.old
  [✓] man pages installed and database updated
  [i] Testing if systemd-resolved is enabled
  [✓] Disabling systemd-resolved DNSStubListener and restarting systemd-resolved
  [✓] Restarting lighttpd service...
  [✓] Enabling lighttpd service to start on reboot...
  [i] Restarting services...
  [✓] Enabling pihole-FTL service to start on reboot...
  [✓] Restarting pihole-FTL service...
  [i] Creating new gravity database
  [i] Migrating content of /etc/pihole/adlists.list into new database
  [✓] Deleting existing list cache
  [i] Neutrino emissions detected...
  [✓] Pulling blocklist source list into range

  [✓] Preparing new gravity database
  [i] Using libz compression

  [i] Target: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
  [✓] Status: Retrieval successful
  [i] Analyzed 130822 domains

  [✓] Creating new gravity databases
  [✓] Storing downloaded domains in new gravity database
  [✓] Building tree
  [✓] Swapping databases
  [✓] The old database remains available.
  [i] Number of gravity domains: 130822 (130822 unique domains)
  [i] Number of exact blacklisted domains: 0
  [i] Number of regex blacklist filters: 0
  [i] Number of exact whitelisted domains: 0
  [i] Number of regex whitelist filters: 0
  [✓] Flushing DNS cache
  [✓] Cleaning up stray matter

  [✓] FTL is listening on port 53
     [✓] UDP (IPv4)
     [✓] TCP (IPv4)
     [✓] UDP (IPv6)
     [✓] TCP (IPv6)

  [i] Pi-hole blocking will be enabled
  [i] Enabling blocking
  [✓] Reloading DNS lists
  [✓] Pi-hole Enabled
  [i] Web Interface password: OJsiVwP0
  [i] This can be changed using 'pihole -a -p'

  [i] View the web interface at http://pi.hole/admin or http://10.12.12.128/admin

  [i] You may now configure your devices to use the Pi-hole as their DNS server
  [i] Pi-hole DNS (IPv4): 10.12.12.128
  [i] If you have not done so already, the above IP should be set to static.

  [i] The install log is located at: /etc/pihole/install.log
Installation Complete!
root@habibza:~#

Access Pi-Hole Admin in Browser

Now, we open via browser.

http://ip-address-pihole/admin

And then, login with password above. If we forget password, we can change it with command 'pihole -a -p'.

Set PC/Device/Gadget Client DNS to IP Pi-Hole

The last, we must set IP address DNS Client point to the pi-hole IP address.

In my case, our PC use IP address 10.12.12.122, and set dns to 10.12.12.128.

And then, browsing anything website, and jump to menu “query log”, we will see result of blocked.

Strengths and Weaknesses Use PiHole DNS

After installing pihole and applying it to our PC or laptop. Then these are the advantages and disadvantages of pihole.

Advantages

  1. No more ads in our browser. Make display web clean and clear.
  2. Block website inidcated include malicious content. So can decrease malware inject in our pc or laptop.
  3. Safe browsing actifity. This important point implementation of pihole. In cyberspace we dont know what web or content which we accidentally visited. We need filter when we visit web and make sure safe when surfing in internet.

Disadvantages

Maybe little disadvantage use pi-hole so far i am use it.

  1. Little bit slowly when browsing. That is the fact when use pihole. I am feel bit slowly. This because pihole is processeing filter. But this is very relative. Depend on spec pihole server and PC that i am use for browsing.
  2. Can not block youtube ads. LOL. 😀

OK. That’s it. Sharing article about pi-hole from me.


Let's Buy Me Coffee.

Buy Me a Coffee at ko-fi.com

https://saweria.co/habibzain
https://ko-fi.com/habibzain
habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox