Tuan-Anh Tran
September 25, 2019

Pi-hole

Posted on September 25, 2019  •  2 minutes  • 379 words

I’ve heard a lot of praise about Pi-hole project but hadn’t gotten around actually trying it yet until recently.

Pi-hole is a network-wide ad-blocking solution via local DNS. You set it up as a local DNS server and it will block all the ads that match the rule from DNS level. This way, you don’t have to setup adblock on each and every devices you have, especially tablets and mobiles. See example of VnExpress without adblock below.

vnexpress without adblock

People usually use Pi-hole with a low powered device like Raspberry Pi (hence the name Pi-hole) but in my case, I already have an Intel NUC lying around as Plex server (running Windows 10). I could just use it instead of setting up sth new.

The easiest way to install Pi-hole is to use Docker. The process is as easy as

pi-hole-config/
├── dnsmasq.d/
├── pihole/
docker run -d --name pihole \
    -p 53:53/tcp \
    -p 53:53/udp \
    -p 80:80 \
    -p 443:443 \
    -v "/c/Users/<USESRNAME>/Documents/pi-hole-config/pihole/:/etc/pihole/" \
    -v "/c/Users/<USESRNAME>/Documents/pi-hole-config/dnsmasq.d/:/etc/dnsmasq.d/" \
    -e ServerIP="<YOUR_HOST_IP>" \
    --dns=127.0.0.1 \
    --dns=1.1.1.1 \
    -e WEBPASSWORD=<PASSWD> \
    --restart=unless-stopped pihole/pihole:latest

And that’s it. Now you can head over to HOST_IP/admin to login and configure Pi-hole. Once it’s done, you can config your router to use the HOST_IP as the default DNS server, and maybe Cloudflare or Google’s DNS as backup. Ah, and make sure to set static IP for your Pi-hole host machine so you don’t have to update router’s setting if the IP changes.

pihole admin

Keep in mind that Pihole is not a complete replacement for browser extension like uBlock origin. You probably still needs that because DNS-based adblocking functionality is quite limited (eg: sites that serve ads on the same domain as content). It’s mostly useful for mobile browser where adblocking is almost non-existent or not good enough.

Follow me

Here's where I hang out in social media