In this post we will see how to edit hosts file (Eg. windows hosts file) to Block unwanted Sites, ads, banners, cookies etc. Hosts file is used to map hostnames to IP addresses.
The hosts file is used by the operating system and it assists the OS in addressing network nodes in a computer network.
The hosts file is named as “hosts” without any extension. It file is a plain text file. In this article we discuss about the structure and location of the hosts file in different operating systems and how we can configure the HOSTS file to block online advertising, or malicious websites.
You can edit the file using any text editor. You can even create the hosts file if there is none.
Location of Hosts file and structure.
The hosts file location is different in different operating systems. Location of the files in some of the operating systems are given below,
1 2 3 4 5 6 7 8 9 10 | Windows NT : %SystemRoot%system32driversetc Windows 2000 : %SystemRoot%system32driversetc Windows XP : %SystemRoot%system32driversetc Windows 2003 : %SystemRoot%system32driversetc Windows Vista : %SystemRoot%system32driversetc Windows 7 : %SystemRoot%system32driversetc Mac OS X 10.2 or newer and iOS : /private/etc/hosts Unix, Unix-like (AIX, HP-UX, IRIX, Linux, Minix, Ultrix etc) , POSIX : /etc/hosts Android : /system/etc/hosts Symbian OS 9.1+ : C:private10000882hosts |
Each line in the hosts file consists of an IP address in the first text field followed by one or more hostnames. These entries are separated by white space or tab. See example below,
127.0.0.1 localhost
The above entry is called “loopback” entry and it defines a local address and can be used to direct the computer to send a packet to itself. See below other examples of Google and Yahoo
1 2 | 216.109.118.74 www.google.com 64.233.183.99 wwww.yahoo.com |
Using Hosts file to Block unwanted sites or content like advertisements
To block any site, you just add the following entry in the hosts file.
127.0.0.1 samplesite.com
In the above example replace “samplesite.com” with which ever site you want to block. The above entry prevents access to the site by redirecting any connection attempts back to the loopback address, that is 127.0.0.1.
So if you want to block “cpalead.com” just add the following entry in the hosts file.
127.0.0.1 cpalead.com
There are hundreads of such ad sites in internet. Finding and adding each one of them to the hosts file may be a tedious job. The MVPS HOSTS file is an excellent choice here. MVPS HOSTS includes most major parasites, hijackers and unwanted Adware and Spyware programs. You can check it here.
Since this method blocks all unwanted sites from downloading content it will speed up internet browsing and is really useful even for blocking download of malicious code from malware sites.
Before you go, subscribe to get latest technology articles right in your mailbox!.