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

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:

wget https://raw.githubusercontent.com/jaykepeters/Scripts/Deployment/Pi-hole_SafeSearch.sh

mv ./Pi-hole_SafeSearch.sh /usr/local/bin/

chmod a+x /usr/local/bin/Pi-hole_SafeSearch.sh

Pi-hole_SafeSearch.sh -e OR Pi-hole_SafeSearch.sh --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?

Quack-quack-go: https://www.home-assistant.io/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.

Sincerely,
Harald

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: images.search.yahoo.com, video.search.yahoo.com. 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 CleanBrowsing.org, 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,
Harald

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

Hi jaykepeters. I have run the commands on my ubuntu server that is running Pi-Hole but it does not seem te work. Anything I am missing? When i run Pi-hole_SafeSearch.sh -enable I get the following

Removing /tmp/safesearch.txt
Retrieving List from Google
194 TLDs
388 Domain
ENABLING SAFESEARCH FOR PI-HOLE
BLOCKING OTHER BAD SITES

I changed the dns on a client but I think that I am still going to normal youtube. Not the restricted one.

Are you using the latest version of the script with sudo?

I got the same output when I ran the command on my machine:

I would have to investigate as to why the client is still going to normal youtube. If it is a desktop, or a mobile device, sometimes restarting the device or flushing the dns cache will solve the issue. If not, please reach out. I have experienced this before myself.

Thanks for the reply. I eventually fixed it by adding the next rules in the /etc/dnsmasq.d/05-restrict.conf file:

cname=www.youtube.com,restrict.youtube.com
cname=m.youtube.com,restrict.youtube.com
cname=youtubei.googleapis.com,restrict.youtube.com
cname=youtube.googleapis.com,restrict.youtube.com
cname=www.youtube-nocookie.com,restrict.youtube.com

Somehow I only had the google and bing cnames.

Above was the only thing for me to get it working.

1 Like

Thanks for letting me know! I will investigate the issue. Please check the git repo every once in a while… A new update is coming soon! :slight_smile:

Firstly thanks jaykepeters for your efforts in getting Safe Search working with Pi-hole.

I can confirm with samad that you need to append the cname code above to the /etc/dnsmasq.d/05-restrict.conf file for YouTube restricted mode to work.

Looking at Jayke’s script it appears the conditional code below is not evaluating to “True” so the YouTube domains are not being echoed to the 05-restrict.conf file. I haven’t tested it but removing the “if” statement will allow the for loop to execute and propagate the conf file. Not sure if that helps?

    # YouTube SafeSearch 
    if [ "$YOUTUBE" == "True" ]; then
        for line in "${ytSS[@]}"
            do echo "$line"  >> "${file}"
        done
    fi

Also Jayke I saw you post requesting a list of search engines so we can block any non Safe Search engines. I think I may have something that might be of use?

1 Like