Install Pi-Hole on Raspberry Pi 4 🌱

Installing Pi-Hole

  1. Log into the Raspberry Pi
  2. Run the following commands in a terminal window
    # update software repositories
    sudo apt update
    # install available software updates
    sudo apt upgrade -y
    # clean up downloaded apt files
    sudo apt clean
    # install pi-hole
    curl -sSL https://install.pi-hole.net | bash
  3. Press Enter until the DNS selection is displayed
  4. Select a DNS provider and press Enter
  5. Press Enter through the rest of the Pi-Hole installer, selecting the defaults
  6. Copy the randomly generated admin password (just in case)
  7. Press Enter to complete the installation
  8. Run the following command to change the Pi-Hole admin password
    sudo pihole -a -p
  9. Enter and confirm the new password
  10. Open a web browser and navigate to http://localhost/admin to view the pi-hole admin interface

Testing Pi-Hole

  1. Back in the terminal, run the following commands to use the local pi-hole instance for DNS
    sudo nano /etc/resolv.conf
  2. Add the following line at the top of the other nameservers

    nameserver 127.0.0.1

  3. Press CTRL+O, Enter, CTRL+X to write the changes to resolv.conf
  4. Back in the web browser, open a new tab and navigate to a site that contains ads, like https://yahoo.com
  5. Watch the Pi-Hole interface to see the ads being blocked