Disable/enable Pi-hole using Apple Shortcuts
Pi-hole is my favourite ad-blocking solution. It runs on Raspberry Pi hooked under my desk, and its only purpose is network-wide DNS filtering. “The World’s Greatest Pi-hole Tutorial 2023” by Crosstalk Solutions is an excellent primer if you are new to the subject.
In most cases, it works like a charm, but from time to time, you just want to disable it temporarily. You can stop it via CLI using pihole disable
command, but this one required SSH login. It just takes too long, and on a mobile device, this is cumbersome. Look at some examples.
# Disable Pi-hole for 30 seconds
pihole disable 30s
# Disable Pi-hole for 8 minutes
pihole disable 8m
Pi-hole during the installation phase lets us install an optional web interface which also allows us to stop/start blocking. This is easier than the previous method but still painful, especially on touch devices.

Apple Shortcuts for the rescue
I spent a few minutes creating this little shortcut that ticks all the boxes for an easy and quick to use method for flipping between Pi-hole blocking states. I built it once on macOS, but thanks to the iCloud sync, I can also use it on iPadOS and iOS.


As you can see, calling Pi-hole API requires an authentication key. You can get it using Web Interface or by checking the Pi-hole setup configuration file.
# Get auth key
cat /etc/pihole/setupVars.conf | grep WEBPASSWORD
# Example how to disable Pi-hole using HTTP request
curl "http://pi.hole/admin/api.php?disable=30&auth=${WEBPASSWORD}"
# Example how to enable Pi-hole using HTTP request
curl "http://pi.hole/admin/api.php?enable&auth=${WEBPASSWORD}"
I hope you found it helpful. Until next time, keep on building cool shit 💩
I feel there is a bit missing from this tutorial. I would love to see a more in depth guide to get this working, especially if you don't have a mac. I think the iphone interface may be a bit different and trying to duplicate what you have hasn't worked for me.
Hi. The actions and the interface of Shortcuts app on iOS, iPadOS and macOS are identical. You are right that I should put a bit more details about the commands that I used, so here they are.
key
is a human readable value (for example 1 minute), thetype
is ``Numberand
value` is number of seconds (this is the value that is going to be passed down the the API call).http://pi.hole/admin/api.php?disable=${THE_OUTPUT_OF_STEP_2}&auth=${AUTH_KEY_FROM_CONFIG_FILE}
Thanks for feedback and hopefully thats helps 😉
Hi Pavel. This works really well. How do I change the notification to display the key of the chosen item instead of the value?
Thanks in advance.
Another option would be to use the Shortcut Run script over SSH
To be fair, I never played around with SSH scripts using Apple Shortcuts. Sounds like a pretty powerful solution. Thanks!
For some reason I couldn’t get your solution to work. Most likely something to do with my using unbound DNS, or my firewall, or something else on my system as what you posted should have worked for me. That’s when I tried the Run script over SSH action. A bit more work to setup (need to copy the public key in the action and add to .ssh/authorized_keys on the pi), but I have it running now.