On Windows apparently this can be achieved for google searches by creating a new CNAME record on your local DNS server for your local Google domain(s) pointing to forcesafesearch.google.com (although its unconfirmed as to whether this method works or is any better than simply editing your hosts file, which is also present on windows and works the same) But I would like to know if its possible to enforce safe search across all search engines using Ubuntu Desktop 18.04 LTS?
2 Answers
I have answered this myself, since the only answer I received didn't work, but it got me thinking and after hours of research and testing I managed to get it working for Google Bing, Duckduckgo and Youtube, however I couldn't find a Yahoo equivalent and in any case I have blocked Yahoo completely since it doesn't (atow) play ball when it comes to privacy.
To lock safe search across the above search engines. Its simply a matter of remapping all of the domains for each search provider to their safe search IP addresses, here's how:
- In Ubuntu press CTR+ALT+T to open a terminal.
- In the terminal enter the following command and press enter, you'll be asked for your password:
sudo gedit /etc/hosts
- In the hosts file in the editor, cut and paste all of the lines as shown leaving any existing entries in your host file as they were. Also I had to dos2unix my /etc/hosts file as somehow I had introduced some invisible and incompatible symbols and consequently some URL to IP mappings weren't working and it took me some hours to realise:
216.239.38.120 www.google.com
216.239.38.120 www.google.co.uk
204.79.197.220 www.bing.com bing.com
204.79.197.220 www2.bing.com
204.79.197.220 www.bing.co.uk
204.79.197.220 www3.bing.com
46.137.218.113 duckduckgo.com
216.239.38.120 www.youtube.com
216.239.38.120 m.youtube.com
216.239.38.120 youtubei.googleapis.com
216.239.38.120 youtube.googleapis.com
216.239.38.120 www.youtube-nocookie.com
Close and relaunch your web browser.
Test safe search is locked for each search engine. For google after a search in the top right corner of the google page it should say SafeSearch on. Using Bing in the drop-down menu at the top right, it should say SafeSearch= Strict, for DuckDuckGo the Safesearch option is no longer displayed under the search box, although if you go into settings its there and allows you to turn SafeSearch Off, however it doesn't actually save the change despite the fact you can click Save. With Youtube you get the following message after a search which indicates SafeSearch is on and you will see that in Settings, Restricted Mode is locked ON:
Some results have been removed because Restricted Mode has been enabled by your network administrator.
-
Is this approach user based? If not is there a way to redirect those pages only for a specific user? I'd like to make my son's account safe, but won't need it for my own account of course. – Torsten Feb 26 '20 at 07:20
You can modify /etc/dhcp/dhclient.conf as specified in this StackExchange answer.
Here's a list of DNS records required for various popular search engines:
- Google:
google.com. CNAME forcesafesearch - DuckDuckGo:
duckduckgo.com. CNAME safe - Bing:
bing.com. CNAME strict - YouTube:
youtube.com. CNAME restrict - Yahoo: As far as I can tell there's no equivalent
Additionally you'll want to set up aliases for localized versions such as google.fi, google.nl etc. You may want to experiment with a record like google.*. CNAME forcesafesearch to see if dhclient.conf accepts wildcards like that.
- 113
- 1
- 10
-
Thanks for the quick reply. I tried the wildcard but wildcards are not accepted: dhclient -v /etc/dhcp/dhclient.conf line 27: semicolon expected. prepend domain-name-servers google.* ^ In any case I couldn't get it to work, setting prepend domain-name-servers directly in dhclient.conf is not the way to go about it these days, according to the following answer its done via the resolvconf utility and /etc/default/bind9, exactly how I have yet to work out: https://askubuntu.com/questions/239169/how-to-edit-etc-resolv-conf-on-ubuntu-12-04 – Sep 10 '19 at 18:19
-
I tried to add blank lines in my comment to aid clarity, by adding 2 spaces at the end of the line following advice in formatting help but nothing I do seems to work and apparently I can only edit a comment for 5 mins so I cant reformat the above comment which doesn't make any sense to me. Can anyone tell me how to add blank lines? Can I just write my comments in pure HTML? – Sep 10 '19 at 18:31
-
A wild guess but usually comments are done by prepending a pound symbol # to the beginning of the line – miestasmia Sep 10 '19 at 20:01