Unforce Google SafeSearch

Unforce Google SafeSearch

·

3 min read

Play this article

Recently, the Iranian government has made changes in the national DNS servers, which causes all DNS requests for Google to be sent to the domain forcesafesearch.google.com (to IP 216.239.38.120), which forces all Google users, regardless of their settings, to use Google with SafeSearch.

How to bypass this?

To bypass this, the system must manually introduce Google's regular search servers (google.com  -  142.250.180.142). For this, it is necessary to use the hosts file available in the operating systems to introduce the IP directly to the system so that it does not request Google's safe search from the country's DNS.

Notice: This solution only works in Windows, macOS and Linux.

For Windows users

On Windows, you need to open the Run window (WinKey + R) and type this as administrator:

notepad C:\Windows\System32\Drivers\etc\hosts

This will open the hosts file of your Windows on a Notepad.

Next, you need to add these lines at the end of the file:

142.250.180.142 google.com
142.250.180.142 www.google.com

Save the file afterward, open cmd and flush the DNS cache by running

ipconfig /flushdns

Now you're all done. Check if it's working by opening google.com, or run nslookup google.com on cmd and see what IP it returns.

For macOS users

Open Terminal and run

sudo nano /private/etc/hosts

Since we use sudo to edit the hosts file, you will be asked to enter the administrator password of your macOS user account. Type your admin password and hit the Enter key.

Note: The cursor doesn’t work in the command line. You'll need to use the arrow keys to navigate between the lines inside the hosts file.

Paste these lines at the end of the file:

142.250.180.142 google.com
142.250.180.142 www.google.com

After that, press CTRL + X on your keyboard. Enter Y to save the changes, and hit the Enter button.

Then, you'll need to flush the DNS cache. to do this, if you're using macOS Monterey or Big Sur, run this:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Else, if you're using macOS Catalina, Mojave, High Sierra, Sierra, Mountain Lion or Lion, run this:

sudo killall -HUP mDNSResponder

Now you're all done. Check if it's working by opening google.com, or run nslookup google.com on your Terminal and see what IP it returns.

For Linux users

Open Terminal and run this:

sudo nano /etc/hosts

Enter the password for sudo when asked.

Paste these lines at the end of the file:

142.250.180.142 google.com
142.250.180.142 www.google.com

After that, press CTRL + X on your keyboard. Enter Y to save the changes, and hit the Enter button.

Then, to flush the DNS cache on Linux, if you are using systemd-resolved, you can use the command followed by --flush-caches.
Alternatively, you can use the resolvectl command followed by the flush-caches option.

sudo systemd-resolve --flush-caches
sudo resolvectl flush-caches

Now you're all done. Check if it's working by opening google.com, or run nslookup google.com on your Terminal and see what IP it returns.