Raspberry Pi and Pi-Hole: Create a Network-Wide Ad Blocker

May 13, 2018
virtualzero
Photo retrieved from pi-hole.net

What is Pi-Hole?

Pi-Hole is software made for the Raspberry Pi that serves as a DNS for local networks. By using the Raspberry Pi with Pi-Hole installed and configured, one can easily rid his or her life of pesky web advertisements that are known to annoy, hog bandwidth, and slow down browsing performance. Read more about Pi-hole via their website: pi-hole.net.

Why the Pi?

  • 1. Affordable Hardware

    The Raspberry Pi is a fantastic choice for this project. The $35 board is budget friendly and has enough horsepower to handle this task under normal conditions.

  • 2. Low Powered

    Since we will be using the Pi as a DNS server, the Pi will remain powered on for very long durations. We need not worry about power consumption however, as the ultra-low powered Raspberry Pi won't break the bank.

  • 3. Because It Is Awesome

    The credit card sized computer is used for countless purposes. Besides its versatility, the Raspberry Pi provides a number of people with their first experience using a Linux operating system.

virtualzero

Let's Get Started!

Note: If you have not yet flashed Raspbian onto an SD Card or installed and configured the Raspbian operating system, please follow this documentation on how to do so before continuing with this tutorial.

  • 1. Installation

    Installation of Pi-Hole could not be easier. Once the Pi is started and you are logged in via SSH, simply type the following into the terminal:

    
    curl -sSL https://install.pi-hole.net | bash

    Press the Enter key and the Pi will download, extract, and install, and install Pi-Hole. Once installation is complete, Pi-Hole will prompt for configuration preferences.

  • 2. Configuration

    DNS Preferences

    The first prompt you will see is to select the upstream DNS service you would prefer to use. Personally, I prefer OpenDNS, and Google is very popular, but any of them will suffice.

    virtualzero

    Press the Space Bar to select your DNS provider, then press the arrow keys to highlight "Ok" and press the Enter key.

    Protocol Preferences

    The next prompt you will see asks if you'd prefer IPv4, IPv6, or both. My network uses the IPv4 protocol, but choose the option(s) that suit your needs.

    virtualzero

    Press the Space Bar to select your protocol choice(s), then press the arrow keys to highlight "Ok" and press the Enter key.

    Configure a Static IP

    This prompt asks if you would like to configure a static IP for the Raspberry Pi. Choose "Yes" here unless you plan on configuring the static IP via your router.

    virtualzero
    Warning

    This is a simple warning that your router may not adhere to our static IP settings. It is a good idea to configure the Pi to have a static IP via your router anyway.

    virtualzero

    Go ahead and press Enter.

    Install the Web Admin Interface

    This is one of the coolest features of Pi-Hole. Make sure that "On" is selected and then press Enter.

    virtualzero
    Enable "Log Queries"

    This prompt asks if you'd like to log queries. As this is where some of the magic happens, you should enable this feature. It will allow you to view DNS queries on your network.

    virtualzero

    Make sure "On" is selected and press Enter. The configuration wraps up and Pi-Hole installs a few additional packages as well as starting the services that it needs to function properly.

    Mission Complete!

    Finally, a prompt is displayed with the heading, "Installation Complete!" You are almost done! This prompt displays some important information that you will want to record. You can take a picture, a screenshot, or write it down. The important stuff is:

    • 1. IP Address

      Locate the section near the top that displays "IPv4:" and "IPv6:", respectively. To the right of each protocol is the IP address that is assigned to your Pi.

    • 2. Web Admin Interface Address

      Near the bottom, you will see an HTTP address that looks like:

      
      http://192.168.1.xxx/admin

      or

      
      http://10.0.x.xx/admin

      Where x = the actual numbers displayed in the prompt.

    • 3. Web Admin Password

      Find your password at the end of the last line of the prompt. It is a mix of upper and lower case letters and numbers. You will need this password to access your Pi-Hole web page.

  • 3. Visit Your Web Admin Page!

    To visit you Web Admin page, type the web interface address that you saved from the previous prompt. You will then be greeted by a sweet web interface where you can view DNS queries, blocked DNS queries, and system resource information in real time.

    virtualzero

    To visit you Web Admin page, type the web interface address that you saved from the previous prompt. You will then be greeted by a sweet web interface where you can view DNS queries, blocked DNS queries, and system resource information in real time.

  • 4. Use the Pi as Your DNS

    This is the last step! All that is left to do is tweak a few settings in the router. For this step, open a web browser and type your router's IP address into the address bar at the top. The address is most likely going to be either:

    192.168.0.1

    or

    192.168.1.1

    or

    192.168.2.1

    If these addresses do not lead you to the web page for your router, refer to the following documentation on locating your router's IP address:

    You should be greeted with a web page similar to the picture below.

    virtualzero

    Login to the router and locate the DNS settings. Refer to your router manufacturer's documentation to locate this if you are struggling. Once you find the DNS settings in your router, simply type the IP address of your Pi into the Primary DNS section like the photo below.

    virtualzero

    Save your changes and exit. You will now enjoy the benefits of an advertisement-free network!