The PiHole Project

How to block ads at home

Ads can take the user’s attention away from the content they are trying to consume, which can be frustrating.

PiHole can help us by blocking ads, improve the browsing experience and protect your privacy and security online.

Changing DNS Settings - Windows 10

setting > Network & Internet > Change adapter options

With the command line, you will be able to check if the DNS updated properly:

ipconfig /all

SelfHosting PiHole

Pre-Requisites!! Just Get Docker 馃悑馃憞

Important step and quite recommended for any SelfHosting Project - Get Docker Installed

It will be one command, this one, if you are in Linux:

apt-get update && sudo apt-get upgrade && curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh && docker version

And install also Docker-compose with:

apt install docker-compose -y

PiHole with Docker

The configuration file that we will use today is:

version: "3"
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - 53:53/tcp
      - 53:53/udp
      - 67:67/udp
      - 80:80/tcp #UI for http
      - 443:443/tcp
    environment:
      TZ: Europe/Madrid
      WEBPASSWORD: password_change_me #optional
      TEMPERATUREUNIT: C
      DNSMASQ_LISTENING: all #local #single #you can get DNSMASQ_WARN if not allowed are trying to query
      DNSSEC: true #false
      PIHOLE_DNS_: 9.9.9.9;149.112.112.112 #127.0.0.1#5053
    # Volumes store your data between container upgrades
    volumes:
      - /home/Docker/pihole/:/etc/pihole/
      - /home/Docker/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/
    # Recommended but not required (DHCP needs NET_ADMIN)
    cap_add:
      - NET_ADMIN
    restart: unless-stopped

Deploy with CLI

Providing that the previous steps are clear, we can jump to our terminal and use:

sudo nano docker-compose.yml

This will open a text editor, where we can paste the following configuration file:

To save, use CTRL+O, then CTRL+X to exit.

Then just deploy the service with:

sudo docker-compose up -d

You are ready to use PiHole, the service will be running in 0.0.0.0:80/admin or localhost:80/admin if you used the configuration file as it is provided.

How to configure PiHole

Testing PiHole - Is my ad-blocker working?

By default, PiHole will be blocking some adds, but how well is our new ad-blocker doing? For that we can use:

Tweaking PiHole - Customizing the block list

In our PiHole Admin panel, we can go to Adlists: http://192.168.3.130/admin/groups-adlists.php


FAQ

How can I check if the new DNS server is working?

nslookup
#try google.com and see the DNS used

This should already give entries to the pihole dashboard at http://your_local_ip/admin/index

How to list the DNS servers used?

resolvectl status | grep "DNS Server" -A2

How to check what is using already port 53?

netstat -tulpn | grep LISTEN

or with:

sudo ss -tuln | grep :53

How can I stop systemd-resolved process at port 53?

sudo systemctl stop systemd-resolve
systemctl disable systemd-resolved.service

How to check services running?

systemctl --type=service --state=running

I had to do:

sudo systemctl stop dnsmasq.service
systemctl disable dnsmasq.service

The inet value is the ipv4 and the inet6 is the raspberry Pi IPV6

How can I check the local ip of my Android device?

Settings > Wifi > Select your Connection > Scroll down and check IP address: You will see something like 192.168.1.111