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.
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.
- Change your network DNS settings to
1.1.1.3and1.0.0.3(Cloudflare Family). - Restart your web browser.
- Attempt to visit a restricted site to verify the block is active.
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 local loopback address), the computer will effectively block the site.
On Windows 10 and 11
- Click the Start menu and type
Notepad. - Right-click on Notepad and select Run as administrator. This is critical; otherwise, you cannot save changes.
- In Notepad, go to File > Open.
- Navigate to the following path:
C:\Windows\System32\drivers\etc - Change the file type filter from Text Documents (*.txt) to All Files (*.*).
- Select the file named
hostsand click Open. - 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.com127.0.0.1 facebook.com
- Go to File > Save and close the application.
On macOS
- Open Terminal (found in Applications > Utilities).
- Type the following command and press
Enter:sudo nano /etc/hosts - Enter your administrator password when prompted (characters will not appear as you type).
- Use the arrow keys to scroll to the bottom of the file.
- Add the sites to block using the same format as Windows:
127.0.0.1 www.instagram.com - Press
Control + Oto write the changes, thenEnterto confirm. - Press
Control + Xto exit the editor. - Flush your DNS cache by typing:
sudo killall -HUP mDNSResponder
127.0.0.1.
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.
- Log into your router's administration panel via your web browser.
- Locate the WAN or LAN settings section.
- Find the DNS Server settings (often set to Automatic or Get from ISP).
- Change the setting to Manual and enter the filtered DNS addresses provided by your chosen provider.
- Save the settings and reboot your router.
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.
- Clear Browser Cache: In Chrome or Edge, press
Ctrl + Shift + Deleteand clear the cached images and files. - Disable Secure DNS: Go to Settings > Privacy and security > Security and toggle off Use secure DNS.
- Flush DNS (Windows): Open Command Prompt and type
ipconfig /flushdns.
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.
Still Having Issues?
💻 Open a Ticket