Pi-Hole is a black hole for internet advertisement.
It works as a DNS server which blacklist domains tied to advertisement. If you use it as your main DNS server and it detects your query is trying to resolve a domain belonging to an advertisement company, it will resolve the domain to IP 0.0.0.0
, preventing the advertisement to load on any computer using this DNS server.
Note that our pi-hole integration is meant to be used in a local network. Please do not try to use this option on a VPS.
Let's imagine the local IP of your BTCPay Server is 192.168.1.2
.
- Connect as root to your server
- Add pihole as an option to your docker deployment
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-pihole"
. btcpay-setup.sh -i
- If your server has a firewall, make sure it allow incoming traffic to port
53 (UDP)
. - Configure your home router DHCP server to use
192.168.1.2
From now everytime a device will connect to your local network, they will automatically use pi-hole as a DNS server. Advertisements will go to a black hole for all devices.
Pi-Hole comes with a very nice admin dashboard to monitor its activity.
It is disabled by default. To enable it, you need to configure PIHOLE_SERVERIP
to the IP of your server:
PIHOLE_SERVERIP="192.168.1.2"
. btcpay-setup.sh -i
If your device is using pi-hole as a DNS server, you should now be able to browse http://pi.hole/admin
to connect to your dashboard.
You can find the admin password in the logs of pihole:
docker logs pihole | grep random
If the password does not work, you can try to reset the password:
pihole.sh -a -p
docker restart pihole
Then running again
docker logs pihole | grep random
You can easily add your local domains to pi-hole.
Imagine you have a NAS (like synology) on your local network with IP 192.168.1.3
, and you want to access it through synology.lan
.
local_dns_list="$(docker volume inspect generated_pihole_datadir -f "{{.Mountpoint}}")/lan.list"
# In most cases this will be /var/lib/docker/volumes/generated_pihole_datadir/_data/lan.list
echo "192.168.1.3 synology.lan" >> "$local_dns_list"
pihole.sh restartdns
You can now browse http://synology.lan
to access your NAS.