Use DNS to force youtube into restricted mode - and Pi-Hole

Special to see the solution tag on an thread running since a few years with many different writers.

Secondly there was not a problem that had to resolved. It is a implementation of controling access to safe versions of sites if available.

Thirdly the implementation is still ongoing and not all is resolved and awaiting for new ideas.

Good observation. I had clicked the solution in error, now corrected.

1 Like

Asking for a little help please…

Where do I ran the script above? should it be in the /root folder or should in be in /opt/pihole folder?
In case I ran the script will the file /etc/dnsmasq.d/05-restrict.conf and the /tmp/safesearch.txt be created automatically?

do have to copy paste something on the /etc/pihole/reges.list and on the /etc/pihole/local.list?

do i have to change permissions on any of the files after running the script?

Thank you for this wonderful guide

1 Like

Thanks for reaching out! You can move the script into /usr/local/bin if you are on Debian/Ubuntu/Raspbian. Make sure that it has execute permissions chmod a+x <path to script>. It will create the file /tmp/safesearch.txt as well as /etc/dnsmasq.d/05-restrict.conf. To enable SafeSearch, use the command -e to enable, or whatever you renamed the file to. Hope that helps. If you have any further questions or need one on one help, please message me directly.



Thank You very much Jayke, its working

You helped make browsing safe for kids again for one more home.


That was my goal :slight_smile:

You’re very welcome!

Thanks, I will test out those rgegexps.

Can i force youtube redirect to invidious with this ? How?? Please dont forget the embedded youtube videos. I need the same functionalities as with the firefox addon invidition:

Possible or not?

That’s good! Haha, I do that too sometimes.

anyone that can help me with this please??

Can you direct message me? I will give you email help too…

Here’s how you would get the script going:


mv ./ /usr/local/bin/

chmod a+x /usr/local/bin/ -e OR --enable

Please check back here for updates as I may release a new version of the script.

My script basically does everything that the above threads here mentioned. All we are doing is editing the dnsmasq (pihole-FTL) configuration files. Many people have helped me out on this one so it is more of a community effort. Thanks for reaching out here though.

1 Like

I get that I’m in the minority here, but can anyone describe how to do this with hassio (homeassistant)? I have pihole running as an add-on and I’m not entirely sure how to access the pihole’s filesystem in particular.

What is hassio?


1 Like

Thnx for all the hard and usefull work. It works really great but is it possible to add yahoo also? Or maybe it is and I do something wrong.


Unfortunately, Yahoo does not yet have a DNS-level SafeSearch enforcement option. At the moment, the only way that Yahoo can be forced into SafeSearch mode is via an https proxy; the method currently in use by many schools and businesses, however there is a workaround to prevent inappropriate visuals from being displayed in search. All you would have to do is block the following domains:, My script should already block these domains. If you are not comfortable with this workaround, then you could just block Yahoo entirely, if nobody on your network uses it. An example of an upstream DNS provider that blocks these domains is, when set to the Family Filter mode. I will be updating the script here soon to have the list of hosts pulled from github, and that way users can suggest new search providers to blocked or forced into SafeSearch mode.

Thnx for the respond and the explanation. Im gonna use the CleanBrowsing DNS with your script and get the most out of it.

Thank you very much,

1 Like

Sounds good! If you have any questions, please let me know.

2 posts were split to a new topic: FTL not running are YouTube restricted mode change