Quickly and Easily Block Adult Content on Ubuntu and Other Linux

Change the DNS to OpenDNS's family shield and it will automatically blocks a huge number of adult websites.
Warp Terminal

If you have children at home who routinely access the computer, you might be worried about them being exposed to adult materials and porn easily available and accessible all over the internet.

Let me share a neat trick on how to block porn and adult content in Ubuntu.

Blocking porn is extremely easy thanks to the wonderful OpenDNS. It is basically DNS blocking. Basically, you will replace your current DNS server with OpenDNS. OpenDNS has a database of adult websites all over the internet. So, whenever an adult website is tried to be accessed, the DNS server redirects to a warning page.

This is the least painful way of blocking adult content because you don’t need to bother about what websites are good or bad.

OpenDNS has free services for home users who want to block access to inappropriate websites on their computer (or router). There are two types of free service available with OpenDNS for content filtering:

  • OpenDNS Home
  • OpenDNS FamilyShield
Various openDNS Plans listed on the official website
OpenDNS Options available

If you are looking for easy configuration to block porn material, go for OpenDNS FamilyShield. You can choose to do the content filtering at two levels:

  • On your computer
  • On your router

If you do it on your router, porn, and other such material will be blocked for all the devices that connect to your home network. In this tutorial, we will see how to do it on your computer.

Block adult content with OpenDNS in Linux

OpenDNS works by changing your DNS to its own DNS server. And with this, it blocks a pre-defined (by OpenDNS community) set of websites which it terms as β€˜harmful’.

Step 1: Open Network Settings

Open the Network Settings. To do this, search for Network Settings in Ubuntu Activities Overview.

Select Network Settings from Ubuntu Activities Overview
Select Network from Dash

Step 2: Select the Network of Choice

Select the type of network you use: Wired or Wireless and then click on the gear icon adjacent to it to edit the connection settings.

Click on the gear icon a adjacent to the network you want to configure
Select Settings for the Network

Step 3: Change the DNS Server

  • Now in here, go to the IPv4 Settings tab.
  • Change the Method to Automatic (DHCP) addresses only.
  • Use these two DNS servers in the field DNS Severs: 208.67.222.123, 208.67.220.123
  • Save it and reboot your computer.
Set the given servers to the DNS field on IPV4 and click on Apply
Set DNS Servers

Once rebooted, you can visit the site below to check if OpenDNS is working.

If everything is successful, then you will get a screen like the one in the screenshot below.

Successfully set up OpenDNS. This is shown when the link is visited.
OpenDNS Success

Possible troubleshoot:

If your settings get changed after each reboot, get it fixed via terminal:

sudo cp /etc/resolv.conf /etc/resolv.conf.auto  

Now, find the correct dhclient.conf file you can use by searching for it in the /etc directory, using the find command.

sudo find /etc -name dhclient.conf
Search for the correct dhclient config file on the /etc location using the find command
Search dhclient config file

Once you find yours, edit it with Gedit using the command:

sudo gedit /etc/dhcp/dhclient.conf

Don't forget to change the location according to the output of the previous search.

Now, add the following line to the document before the require subnet-mask command:

supersede domain-name-servers 208.67.222.123,208.67.220.123;

Save and exit. Now restart the network in Ubuntu:

sudo ifdown eth0 && sudo ifup eth0

You may be required to change eth0 to your own network device’s name if it uses a non-standard name.

Read here for more details and set it on your router. I hope you were able to block adult content as easily as you find the Wi-Fi access points in Ubuntu.

If you want to go to the next level, set up Pi Hole at router level and enjoy ad-free browsing with even better control.

How to Set Up Pi-hole to Get an Ad-free Life
Pi-hole is a DNS-based advertisement blocker. Unlike a Chrome or Firefox extension, a Pi-hole can block ads even on your TV! So let’s see how to install and take advantage of this amazing tool! What is Pi-hole? Pi-hole is a DNS Server. It blocks advertisement serving domains. Set it
About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries πŸ•΅οΈβ€β™‚οΈ

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

itsfoss happy penguin

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.