Hosts: Block the bullshit web

Advertisements, tracking scripts and other countless lines of code downloaded on to your machine to spam and monitor you whenever you connect to the internet.

Host is a project to block advertisements, tracking scripts and other websites including pornographic content using this host file.

I also have integrated a feature to toggle the Host file on/off as per the need. Currently, this approach is available for Windows operating system.

Hosts file

This hosts file consolidates several reputable hosts files, and merges them into a unified hosts file with duplicates removed.



hosts.bat file is used to toggle hosts file on and off via UAC permission.


How to setup

  1. Download the ‘hosts’ file and replace the hosts file in C:\Windows\System32\drivers\etc

  2. Alternatively, you can download the desired version from Mr Steven Black's GitHub repository and download the required hosts file (Preferable -> Unified hosts + fake news + gambling + porn + social).

  3. If you download from above Steven Black’s repository, then append the new hosts file content (modify as require) to existing hosts file at C:\Windows\System32\drivers\etc

  4. Win + R -> regedit -> HKEY_CLASSES_ROOT\batfile\shell

  5. Double click (Default) and change the value to runas

  6. Win + R -> regedit -> Enter

  7. Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache

  8. Double click Start and change the value to 4

  9. Win + R -> services.msc

  10. Search = DNS Client -> properties and verify Start type = Disabled and all other buttons are disabled

How to use

We might often have to turn the hosts file on and off, for various reasons. Doing this by navigating all the way to C:\Windows\System32\drivers\etc and making necessary changes will be a pain. So in this section we will create shortcut to toggle the hosts file whenever required. There are two methods for this, follow whichever suits you.

Method 1

  1. Download hosts[dot]bat file and save it in C:\Windows\System32

  2. Win + R -> hosts -> Enter -> Yes -> hosts file will be disabled/enabled

Method 2

  1. Download hosts[dot]bat file and save it at your desired location

  2. Click the Start button

  3. Start typing Command Prompt in the search box

  4. Right-click Command Prompt once it appears in the search results, and select Pin to Taskbar

  5. While holding SHIFT, right-click the black Command Prompt icon in the taskbar

  6. Select Properties from the context menu that appeared

  7. Add following to Target field: %windir%\system32\cmd.exe /c “drive\desired path\hosts.bat”

  8. Go to General tab and change the name to Toggle Hosts and add a fancy icon if you want

  9. Access with shortcut -> Win + pinned location -> Enter -> Yes -> hosts file will be disabled/enabled