niels segers

Mimicking Pi-hole's ad blocking

cover

Aug 15, 2020

I have been running Pi-hole in my home network for quite a while now but often had issues combining it with other services running in the network. So I decided to run an incredibly basic version of it myself.

Under the hood Pi-hole is nothing more than a dnsmasq server which caches all of your dns records and a bunch of dnsmasq address= configurations that resolve to nothing.

So what do you need? A single dnsmasq container will do and an ad blacklist found here.

Simply start up a dnsmasq container of your choice and create two volumes. One for the blacklist you just downloaded (mount it wherever you feel like) and one for the dnsmasq.conf config file itself as we still need to point dnsmasq to the blacklist.

yaml

1 2 3 4 5 6 7 8 9 10 11 12 version: "3" services: dnsmasq: image: jpillora/dnsmasq ports: - 5380:8080 - 53:53/udp restart: always volumes: - /home/foo/dnsmasq/dnsmasq.conf:/etc/dnsmasq.conf - /home/foo/dnsmasq/dnsmasq.blacklist.txt:/path/to/dnsmasq.blacklist.txt

In your dnsmasq.conf you place the following line:

conf-file=/path/to/dnsmasq.blacklist.txt

Point your router to your newly setup DNS server, restart your container and there we go. Everything defined in the blacklist will simply not resolve. A basic Pi-hole configuration that's entirely under our own control with a minimal setup. 😎