Home › Knowledgebase › KB-576

How to manage and block distracting websites using DNS filtering and Hosts files

Summary

This guide helps you troubleshoot and resolve: How to manage and block distracting websites using DNS filtering and Hosts files. Follow the steps below to fix the issue.

Quick Tip: Need immediate assistance? 💻 Open a Ticket

Common Causes

Maintaining productivity in a home office or small business environment often requires limiting access to distracting websites. Depending on your technical skill and the level of control required, you can achieve this using DNS filtering for a network-wide approach or editing the local Hosts file for device-specific restrictions.

Quick Fix Steps

If you need a fast solution without modifying system files, we recommend using a filtered DNS service such as Cloudflare for Families or OpenDNS. This redirects your internet traffic through a server that automatically blocks known distracting or malicious domains.

  1. Change your network DNS settings to 1.1.1.3 and 1.0.0.3 (Cloudflare Family).
  2. Restart your web browser.
  3. Attempt to visit a restricted site to verify the block is active.
Important: DNS filtering can be bypassed by tech-savvy users who change their own DNS settings on their devices or by switching to mobile data. This method also does not block traffic if a device is configured with static DNS addresses.

Detailed Instructions

Method 1: Using the Hosts File (Device Specific)

The Hosts file is a local text file that maps hostnames to IP addresses. By mapping a website to 127.0.0.1 (the IPv4 loopback address) or ::1 (the IPv6 loopback address), the computer will attempt to direct traffic to itself, effectively blocking the site. Please note that the Hosts file only blocks domain names; it cannot block direct connections to IP addresses.

Backup Warning: Always create a backup copy of the Hosts file before making any changes. If an error occurs during editing, you can restore the original file to regain internet access.

On Windows 10 and 11

  1. Click the Start menu and type Notepad.
  2. Right-click on Notepad and select Run as administrator. This is critical; otherwise, you cannot save changes.
  3. In Notepad, go to File > Open.
  4. Navigate to the following path: C:\Windows\System32\drivers\etc
  5. Change the file type filter from Text Documents (*.txt) to All Files (*.*).
  6. Select the file named hosts and click Open.
  7. Before editing, save a copy of this file to your Desktop as hosts.bak.
  8. Scroll to the bottom of the document and add the websites you wish to block on new lines using this format:
    • 127.0.0.1 www.facebook.com
    • 127.0.0.1 facebook.com
    • ::1 www.facebook.com
  9. Go to File > Save and close the application.

On macOS

Administrator Privileges: Editing the Hosts file on macOS requires administrator privileges. You will be prompted for your password when using the sudo command.
  1. Open Terminal (found in Applications > Utilities).
  2. Type the following command and press Enter: sudo nano /etc/hosts
  3. Enter your administrator password when prompted (characters will not appear as you type).
  4. Before editing, it is recommended to create a backup via the terminal using: sudo cp /etc/hosts /etc/hosts.bak
  5. Use the arrow keys to scroll to the bottom of the file.
  6. Add the sites to block using the same format as Windows: 127.0.0.1 www.instagram.com or ::1 www.instagram.com
  7. Press Control + O to write the changes, then Enter to confirm.
  8. Press Control + X to exit the editor.
  9. Flush your DNS cache by typing: sudo killall -HUP mDNSResponder
Bypass Warning: Tech-savvy users can bypass Hosts file blocks by using a VPN, changing their DNS settings, or accessing the site via its IP address rather than the domain name.

Method 2: DNS Filtering (Network Wide)

DNS filtering is more effective for organisations as it covers all devices connected to the router, including mobile phones and tablets.

Router Configuration Examples

  1. Telstra: Log into the Telstra Gateway interface. Navigate to Advanced Settings > Internet > DNS Settings. Change from Automatic to Manual and enter your filtered DNS addresses.
  2. Netgear: Log into the router admin page. Go to Advanced > Setup > Internet Setup. Under Domain Name Server (DNS) Address, select Use These DNS Servers and enter your filtered addresses.
  3. TP-Link: Log into the TP-Link web interface. Navigate to Advanced > Network > WAN. Change the DNS settings from Automatic to Manual and enter the primary and secondary DNS servers.
  4. ASUS: Log into the ASUS router settings. Go to WAN > Internet Connection. Set WAN DNS Setting to Yes and enter your preferred DNS filtering servers.
If you are using a managed firewall provided by 220 Internet Services, you may have access to a more advanced web filtering dashboard. Please Open a Ticket to request a review of your current filtering policies.

Troubleshooting

The website is still loading

Modern browsers often cache DNS records or use "DNS over HTTPS" (DoH), which bypasses local Hosts files and router settings.

macOS DNS Cache Troubleshooting

If you have edited the Hosts file on macOS and the site is still accessible, you may need to flush the DNS cache manually.

  1. Open Terminal.
  2. Type the following command and press Enter: sudo killall -HUP mDNSResponder
  3. If you receive a "command not found" error, try: sudo dscacheutil -flushcache
  4. Enter your administrator password when prompted.
  5. Restart your web browser to clear any internal DNS caches.

I cannot save the Hosts file

This is almost always a permissions issue. Ensure you have launched your text editor as an administrator. On Windows, you must right-click the application icon to find the Run as administrator option. On macOS, ensure you are using the sudo prefix in Terminal.

Still Having Issues?

Need more help? If the issue persists after trying these steps, please open a support ticket and our team will assist you.

💻 Open a Ticket