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

**URL:** <https://discourse.pi-hole.net/t/use-dns-to-force-youtube-into-restricted-mode-and-pi-hole/1996>\
**Category:** General\
**Created:** [March 3, 2017, 5:54pm UTC](https://discourse.pi-hole.net/t/use-dns-to-force-youtube-into-restricted-mode-and-pi-hole/1996 "2017-03-03T17:54:42Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![jpgpi250](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jpgpi250/32/286_2.png) [@jpgpi250](https://discourse.pi-hole.net/u/jpgpi250)\
**Post date:** [March 17, 2017, 11:31am UTC](https://discourse.pi-hole.net/t/use-dns-to-force-youtube-into-restricted-mode-and-pi-hole/1996/15 "2017-03-17T11:31:25Z")

</div>

Reference for domain names [here](https://support.opendns.com/hc/en-us/articles/227986807-How-to-Enforcing-Google-SafeSearch-YouTube-and-Bing) and [here](https://www.paloaltonetworks.com/documentation/61/pan-os/pan-os/url-filtering/safe-search-enforcement.html)

Create a file **/etc/dnsmasq.d/05-restrict.conf** , us a higher number if you already have a 05 entry. Don't use 01 (pihole core) 02 (pihole dhcp) or 03 (pihole wildcards):

```auto
# reference: https://support.opendns.com/hc/en-us/articles/227986807-How-to-Enforcing-Google-SafeSearch-YouTube-and-Bing

# YouTube
# you can also implement a moderate setting
# replace restrict.youtube.com with restrictmoderate.youtube.com
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

# SafeSearch
cname=www.google.com,forcesafesearch.google.com

# Bing Family Filter
cname=www.bing.com,strict.bing.com

```

test (for typo's) - should report **dnsmasq: syntax check OK.**

```auto
dnsmasq --test

```

edit your **hosts** file

```auto
sudo nano /etc/hosts

```

enter the following entries (leave the original content, just add the following)

```auto
216.239.38.120	restrict.youtube.com
216.239.38.119	restrictmoderate.youtube.com
216.239.38.120	forcesafesearch.google.com
204.79.197.220	strict.bing.com

```

restart the dns service

```auto
sudo service dnsmasq restart

```

I don't think it's really necessary to update the addresses regularly, since it would brake protection for a lot of people worldwide, if they changed, but you can run (from time to time) the script that's listed above. The **script has changed** to allow for the additional entries to be processed correctly!

haven't tried safe search or youtube ([kingmoocow](https://discourse.pi-hole.net/users/kingmoocow) seems to have had good results) but bing produces this:

 ![](https://discourse.pi-hole.net/uploads/default/original/1X/d73a61919ca70b2605d6e1d0eb24a16916f851a3.jpg)

---

_[View the full topic](https://discourse.pi-hole.net/t/use-dns-to-force-youtube-into-restricted-mode-and-pi-hole/1996)._
