How to block advertisements and malicious resources with Windows hosts file
What is Windows hosts file?
Windows hosts file is a computer file used by the Microsoft Windows operating system to map hostnames to IP addresses. The hosts file is a plain text file without an extension, and is conventionally named hosts.
Malicious internet resource blocking
Specially crafted entries in Windows hosts file and additional custom replacement hosts files (relating to size and performance) can be utilized to block online advertisements, or the domains of known malicious resources and servers that contain, consist, or relate to adware, spyware, botnets and other forms of malware and cyber criminal activity. Blocking malicious sources can be achieved by adding entries into the hosts file for the malicious domains to redirect requests over to another domain that does not exist or to a harmless destination such as a localhost or security tracker.
In other words, you can either manually edit your Windows hosts file using the instructions described below or replace your Windows hosts file with a custom hosts file to block malicious resources.
How to locate Windows hosts file
The video and instructions below detail how to find the Windows hosts file.
1. Run Microsoft Notepad as an administrator: Navigate to Windows Start Menu > All Programs > Accessories > Notepad, right click the Notepad icon, and select Run as administrator.
2. Once the Notepad application has booted, click File on the top menu and select Open or type Ctrl+O.
3. On Windows 7/8 navigate to (C:) > Windows > System32 > drivers > etc.
- Windows XP/2003/Vista/2008
C:\Windows\System32\Drivers\Etc - Windows NT/2000
C:\Winnt\System32\Drivers\Etc - Windows 95/98/Me
C:\Windows
4. Click the drop down menu at the bottom of the window that currently displays “Text Document (*.txt)” and change it to the “All Files” option and open the hosts file when visible. The hosts file does not have an extension such as .txt and .jpg, which is why you have to show All Files.
HOW TO BLOCK MALICIOUS RESOURCES USING THE HOSTS FILE
To block malicious resources using Windows hosts file, include additional entries at the bottom of the hosts file depending on your version of Microsoft Windows (The example Windows hosts files below by default block the Text Enhance ad serving platform, shown in red.) or install our custom host file that will automatically block hundreds of thousands of unethical sources.
Hosts file installation (.zip)
1. Download hosts .zip file. (Currently Unavailable)
2. To open compressed hosts file, right click and select Extract all. Choose your destination for the folder and file (the hosts file is located inside a folder).
3. Remove the extension from the file, such as .txt. and replace (overwrite) the new hosts file with your existing file using the location described above.
For Windows XP or for Windows Server 2003
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
127.0.0.1 text-enhance.com
For Windows Vista or for Windows Server 2008
# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
::1 localhost
127.0.0.1 text-enhance.com
For Windows 7
# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handle within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 text-enhance.com