Pi-Hole Docker Image on Raspberry Pi


  1. Flash your Raspbbery Pi with: Hypriot OS
    1. https://blog.hypriot.com/downloads/
  2. Boot the Raspberry, and login with The default credentials using PuTTY
    1. user: pirate
    2. password: hypriot.
  3. Run the following commands to disable the listener on port53
    1. sudo systemctl disable systemd-resolved.service 
    2. sudo service systemd-resolved stop
  4. Run the following to install Pi-Hole:
    1. docker pull pihole/pihole
  5. Run the following to start Pi-Hole:
  6. IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')"  # May not work for VPN / tun0IPv6_LOOKUP="$(ip -6 route get 2001:4860:4860::8888 | awk '{for(i=1;i<=NF;i++) if ($i=="src") print $(i+1)}')"  # May not work for VPN / tun0
    IP="${IP:-$IP_LOOKUP}"  # use $IP, if set, otherwise IP_LOOKUP
    IPv6="${IPv6:-$IPv6_LOOKUP}"  # use $IPv6, if set, otherwise IP_LOOKUP
    DOCKER_CONFIGS="$(pwd)"  # Default of directory you run this from, update to where ever.
    
    echo "### Make sure your IPs are correct, hard code ServerIP ENV VARs if necessary\nIP: ${IP}\nIPv6: ${IPv6}"
    docker run -d \
        --name pihole \
        -p 53:53/tcp -p 53:53/udp \
        -p 67:67/udp \
        -p 80:80 \
        -p 443:443 \
        -v "${DOCKER_CONFIGS}/pihole/:/etc/pihole/" \
        -v "${DOCKER_CONFIGS}/dnsmasq.d/:/etc/dnsmasq.d/" \
        -e ServerIP="${IP}" \
        -e ServerIPv6="${IPv6}" \
        --restart=unless-stopped \
        --cap-add=NET_ADMIN \
        --dns=127.0.0.1 --dns=1.1.1.1 \
        pihole/pihole:latest
    
    echo -n "Your password for https://${IP}/admin/ is "
    docker logs pihole 2> /dev/null | grep 'password'



  7. Configure your hardware (router is recommended, had problems doing it on a windows 10 pc solely):
    https://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245 
    Static IP:
    1. enter command: sudo nano /etc/network/interfaces
    2. copy paste it a good place, save:
    3. # Static IP address
        write_files:
        - content: |
        persistent
        # Generate Stable Private IPv6 Addresses instead of hardware based ones
        slaac private
        # static IP configuration:
        interface eth0
        static ip_address=192.168.1.31/24
        # static ip6_address=fd51:42f8:caae:d92e::ff/64
        static routers=192.168.1.1
        static domain_name_servers=192.168.1.1 8.8.8.8
        path: /etc/dhcpcd.conf

        #source: https://github.com/hypriot/flash/blob/master/sample/static.yml
    4. run following command to restart network service: systemctl daemon-reload
    or you can reserve the address using your router:

    Other useful stuff:
    type in the terminal:
  1. Pi's IP address: hostname -I
  2. Your router's IP address: ip route | grep default
  3. Change password: sudo docker exec -it [Container name of your pihole, e.g. pihole] pihole -a -p
  4. Access other pi commands from docker: sudo docker exec -it [Container name of your pihole, e.g. pihole] pihole [command key here]
  5. Reconfigure PiHole through UI - possibility to set static IP: sudo docker exec -it [Container name of your pihole, e.g. pihole] pihole -r
  6. The pi-hole will automatically restart  on boot or in the event of a crash
  7. https://discourse.pi-hole.net/t/the-pihole-command-with-examples/738
  8. Access to change hostname of your pi in this file: sudo nano /boot/user-data

Kommentarer

Populære opslag fra denne blog

Nintendo Switch load Payloads from Raspberry Pi

Docker