Service definitions for easy Pi-hole group blocking.
Inspired by AdGuard Home's "blocked services".
Beside ad tracking and malicious site filtering, Pi-hole comes in handy to block DNS access to various internet services that often violate e.g. the guidelines of the Center for Humane Technology (which b.t.w. is supported by people actively engaging for the companies in critique) or - more important - are not following the guidelines of my all-time heroes of the Electronic Frontier Foundation.
With Pi-hole's group filter functionality you can add the services you want to block for e.g. parental control, workplaces, or self focus, organize them into groups and then assign them to clients.
To do so, we need to add
- (a) wildcard domain(s) for the service in question;
- link the wildcard domain(s) to a group;
- link a client to this group.
Unfortunately (I), at the moment (2021-09-07) there's no way to add wildcard domains by lists: The handy "adlist" feature only supports exact matched domain names, but neither regex nor wildcard domains (which get automatically converted to wildcard).
Thus, you need to run a script, serviceblock, for adding the the wildcard domains and add them to your desired group.
Unfortunately (II), I couldn't find built-in ways for CLI
- to create groups from the command-line
- to map groups with (regex) domains with groups.
Therefor this quite tedious work needs to be made manually. The auto-generated comments can help you a bit.
Prerequisites: pi-hole (tested with 5.2.4) with web-admin UI up and running. Remote shell access to RPi.
local-computer>ssh pi@pi-hole-IP
rpi>sudo su -
git clone https://github.com/karstengresch/pi-hole-service-blockers.git
# Should list all services to block:
./serviceblock -l
# be cautious - creates some domains:
# ./serviceblock -b --a
# Example: blocking tiktok only.
./serviceblock -b tiktok
- Head over to the admin UI->Group Management.
- Create a group for each service to block, e.g. block-tiktok.
- (Tedious!) Link all created regex domains with matching comment (e.g. serviceblock:tiktok) to the created group and remove the default group, if desired (my setup).
- Link client to the group.
- remove domains for all or for specific services
- create group for each service
- link this service-group to created regex domain
- command to link services to client
- create a "block-" list for all services for copy and paste group creation
- better documentation
- UI
- time based blocking/unblocking
Issues/pull requests welcome.
- 9gag
- amazon
- cloudflare
- dailymotion
- dazn
- discord
- disneyplus
- ebay
- epicgames
- gutefrage
- hulu
- imgur
- mail(.ru)
- netflix
- ok
- origin
- snapchat
- spotify
- steam
- telegram
- tiktok
- tinder
- twitch
- viber
- vimeo
- vk
- youtube
- Kids will easily circumvent this.
At least not my kids at the moment, at least not for all equipment (they do can pass the entire local network, but that's another story). - "I have setup (A|B|C)" that doesn't allow recognizing clients.
OK, then this approach will not work.
This project isn't affiliated with the official Pi-hole project.
No warranties, use at your own risk.