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

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