Domain block timeout

hi there. sorry i'm a newb here and i wasn't able to file this under "feature request" for some reason.

i'd like to request a feature for domain blocking and that is a timeout feature. eg. you block a domain for X hours or X days.

i use pihole on my personal network and i like to lock myself out of social media and other websites to reduce distractions but sometimes i find myself logging into pihole to disable the block so i can cheat and unblock websites i previously locked myself out of.

what do you guys think? if its not a popular request i'm thinking of implementing this myself, but i do think it would be a useful addition to pihole.

cheers, matthew.

This looks like a similar open feature request which is here

If you're up for a bit of hacking, this can be achieved today using Pi-hole's Groups and some scripting.

  • In Groups create a new group called Focus
  • In Domains create new blacklist rules for the social media and other websites to block access
  • Edit these blacklist rules and change them to just the new Focus group (no longer in Default)
  • In Clients find your computers and click Add and change their group so they are in both Default and Focus groups

If the Focus group is turned off you get all the normal blocking from Default but not the social media. If the Focus group is turned on you get the blocking in Default plus the extra blocking from Focus.

Test this manually to make sure it's working as intended.

Finally, you can schedule the turning on and off of the Focus group using cron. You have to know how crontab entries are formatted – this reference will help.

Open crontab for editing

crontab -e

Add in your lines, eg to turn on Focus (block social media) at 9am and turn it back off (enable social media) at midday every day of the week:

#Enable Focus:
0 9 * * *  sudo sqlite3 /etc/pihole/gravity.db "update 'group' set 'enabled'=1 where name='Focus';"; /usr/local/bin/pihole restartdns reload-lists &>/dev/null
#Disable Focus:
0 12 * * *  sudo sqlite3 /etc/pihole/gravity.db "update 'group' set 'enabled'=0 where name='Focus';"; /usr/local/bin/pihole restartdns reload-lists &>/dev/null

Save your edits and quit the editor. Now the Focus group will be turned on and off automatically according to the schedule you specified.

thanks for your reply. seems complex but it could be an option thanks. i was probably going ot write a crontab that locks me out of the admin console for a period of time but i'll try this as well. i dothink an option to set timers on blocked domains as you add them would be a really useful feature though.

Because blocked domains are the end result of adlists, blacklists and whitelists, I think the best way to manage them is via Groups, as Groups allow the slicing and dicing of different blocking for different roles, individuals or devices.

I agree that having a timer feature right there in the user interface would be a great feature. If it was made available for Groups it could be used to control all the above.

I picture it as a new section called Timers where a set of On and Off times can be configured as a collection and given a name. And then in Groups, instead of having just Enabled or Disabled as now, it would be Enabled, Disabled or Timed. If Timed is selected you select the Timer name to apply.