How to force Google Safe Search using DNS or Pi-Hole

Question came from a user on the Youtube community on how to force Google Safe Search for their network.

SafeSearch is a feature in Google Search and Google Images that acts as an automated filter of pornography and potentially offensive and inappropriate content. On November 11, 2009, Google introduced the ability for users with Google Accounts to lock on the SafeSearch level in Google’s web and image searches.

There are multiple ways to implement SafeSearch enforcement, and we will address the two easiest method:

Method 1: Using Windows DNS hosts file

Follow these steps to force Google SafeSearch on Windows machines:

  1. In Windows, click the Windows key and type Notepad.
  2. Right click on Notepad and choose Run as Administrator.
  3. Click Yes when Windows asks if you want this program to make changes.
  4. In Notepad, open your hosts file. In most Windows installations, this is located at: C:\Windows\System32\drivers\etc\hosts.
  5. Click the Windows key, type cmd and hit enter. This will open Command Prompt.
  6. Enter the command ping and note the IP address. The IP address will look something like:
  7. Create an entry at the end of hosts file with the IP address you obtained. For example: #forcesafesearch.
  8. Save the hosts file.

To confirm SafeSearch is on, open and check that SafeSearch is on by default and can’t be turned off.

Method 2: Using Pi-Hole DNS server

If you are running Pi-Hole server on Windows or Linux , you can follow these steps to enforce Google SafeSearch using Local DNS server, the benefit of this method that all client on your network will benefit from this enforcement, whereas method 1 must be applied to Windows clients one by one, no solution for mobile clients either.

  1. Using Windows CMD or Linux Terminal, enter the command ping and note the IP address. The IP address will look something like:
  2. Login to your Pi-Hole server using the Web UI (GUI).
  3. Go to Local DNS from menu on the left -> DNS Records.
  4. Create an entry: Domain and IP address
  5. You may need to wait for DNS cache (Local, Browser or Pi-Hole itself) to expire in order for you to see the effect.