Pi-Hole on Docker using OMV Raspberry Pi 4 “Network Wide Ad-Blocker”

In this segment we are going to show you how to configure “Pi-Hole on Docker using Openmediavault Raspberry Pi 4 “Network Wide Ad-Blocker “

What is Pi-Hole ?

Pi-hole is a Linux network-level advertisement and Internet tracker blocking application which acts as a DNS sinkhole (and optionally a DHCP server), intended for use on a private network. It is designed for use on embedded devices with network capability, such as the Raspberry Pi, but it can be used on other machines running Linux and cloud implementations.
Pi-hole has the ability to block traditional website adverts as well as adverts in unconventional places, such as smart TVs and mobile operating system adverts.

pihole

OpenMediaVault Versions :

        EquipmentEquipment Required :

    raspberrypi Raspberry Pi All Models
    raspberrypi Micro SD Card “Minimum 8 GB”
    raspberrypi Power Supply
    raspberrypi Ethernet Cord for LAN Connection
    raspberrypi External Hard Drive or USB Drive

         raspberrypiOptional :

    raspberrypi Raspberry Pi Case
    raspberrypi Keyboard
    raspberrypi Mouse

    Pi-Hole

    Checkout official website : pi-hole

    Docker-compose

    version: "3"
    
    # More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
    services:
      pihole:
        container_name: pihole
        image: pihole/pihole:latest
        ports:
          - "53:53/tcp"
          - "53:53/udp"
          - "67:67/udp"
          - "80:80/tcp"
          - "443:443/tcp"
        environment:
          TZ: 'Asia/Kolkata'
          # WEBPASSWORD: 'set a secure password here or it will be random'
        # Volumes store your data between container upgrades
        volumes:
           - './etc-pihole/:/etc/pihole/'
           - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
        dns:
          - 127.0.0.1
          - 1.1.1.1
        # Recommended but not required (DHCP needs NET_ADMIN)
        #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
        cap_add:
          - NET_ADMIN
        restart: unless-stopped

    Step 1 : Configuring Openmediavault Network Interface

    • First of all we need to configure our DNS servers from Openmediavault Network Interface.
    • We need to navigate on Network –> Interfaces and edit the Network.
    • After that configure the DNS Server from Advanced settings to 127.0.0.1 or 1.1.1.1 as shown in Pi-Hole Docker-compose.

    omv

    Step-2 : Create Network for Pi-Hole

    • Now we need to open Docker and navigate to Networks then click on create for new network.
    Network name  : "Type the name of your choice."
    Network diver : "Select macvlan"
    Subnet        : "Type Openmediavault IP Address/ Number of Address available on router"
    Gateway       : "Type router IP Address"
    Parent        : "Openmediavault Interface Name"

    omv

    Step 3 : Download the Official Pi-Hole Docker image.

    • We need to search for Pi-Hole container from the search box and chose the official Pi-Hole image.

    Pi-Hole on Docker

    Step 4 : Run Pi-Hole Image

    • Now, we need to select Pi-Hole image and click on run image.
    • After that fill the details as mentioned below the picture.

    Pi-Hole

    - General 
    Container name : pihole "You can choose any name" 
    Restart Policy : "always" 
    
    - Networking 
    Network mode : "Macvlan" 
    Host name : PcMac "Choose a name of your choice" 
    
    - Macvlan settings 
    Select macvlan network : "Select the network which we have created" 
    IP Address : "Type the IP Address for your Pi-Hole"
    
    -Environment variables
    ServerIP    : "Type the Pi-Hole IP Address, which we created"
    TZ          : "Asia/kolkata", Type your Time Zone here
    WEBPASSWORD : "Password of your choice"
    
    - Volumes and Bind mounts
    Create folder 1 : pihole
    Create folder 2 : pihole/DNSmasq
    
    - Extra arguments
    -p 53:53/tcp -p 53:53/udp -p 67:67/udp -p 80:80/tcp -p 443:443/tcp

    Step 5 : Access Pi-Hole Server Web Interface

    • To access the Pi-Hole web interface we need to type the Pi-Hole IP Address/admin.
    • But our Pi-Hole is not yet ready for blocking Ads on our Network.
    • To block the Ads on the Network we need to update Pi-Hole IP Address to our Router DNS.

    Pi-Hole

    http://Pi-Hole IP Address/admin/

    Step 6 : Updating Pi-Hole IP Address to Router DNS

    • Now, we need to Login to our Router and then Navigate to DNS Settings.
    • Then we need to enter the Pi-Hole IP Address to our Router Primary DNS Address.
    • So, the traffic can route through the Raspberry Pi and Block ads with Pi-Hole.
    Primary DNS Address   : "Pi-Hole IP Address"
    Secondary DNS Address : "Cloudflare DNS Address i.e 1.1.1.1"

    router DNS

    Step 7 : Reset Pi-Hole Password

    • If you forgot your Pi-Hole password you can reset it anytime by using this command.
    docker exec -it pihole pihole -a -p

    Now, you are all set to use Raspberry Pi 4 as Pi-Hole Network Wide Ad-Block Server.
    If you face any issue regarding this article please share your thoughts.
    Enjoy using Pi-Hole on Docker using Openmediavault.

    Smile (.”_”.)

    3 thoughts on “Pi-Hole on Docker using OMV Raspberry Pi 4 “Network Wide Ad-Blocker””

    1. Pingback: How to Install Docker on Raspberry Pi All models - PcMac

    Leave a Reply

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

    fifteen − eight =