Free and Opensource software review, Operating system review, Tips and Tricks, System tweaks, troubleshooting, Tools and Techniques, Hacks

How to use hosts file to block a website or its services?

Block Websites using Hosts fileThe hosts file is a system file which is used to map an IP address to its hostname. The operating system (any operating system) checks the Hosts fie before it queries for the DNS server. This pre-check of Hosts file enables us to override the DNS settings i.e. the original DNS addresses. We can even block or even redirect a hostname to a different IP. Setting the Hosts file will even prevent applications from following the original DNS o block them from accessing the internet. Another main advantage of Hosts file is that it can even block ads and other third party page analytic’s and unwanted banners by blocking their connection using the Hosts file. This could even boost your browsing speed. Here is how you can block unwanted websites and connection attempts using a Hosts file.

As mentioned earlier, Hosts file is a mapping of IP addresses to Host names. i.e. there is a list of Host names which are mapped to a specific IP addresses. The hack behind blocking the website is by redirecting a particular host name to your own system. Your system in general is specified by the IP address

Hosts file is located at various locations depending on the operating system your system uses.

Host file location in Windows

In windows Xp, Vista and 7 hosts file is located in the location C:Windowssystem32driversetchosts

The C:Windows  in the above location refers to %SystemRoot% which is the drive where you have installed the Windows Operating System.

HOST FILE location IN Linux

In windows Xp, Vista and 7 hosts file is located at /etc/hosts.

Manipulating Hosts File

The default contents of  hosts file may look something like this.               localhost
::1                         localhost               localhost

From the above entry we can conclude that the IP address is mapped to localhost i.e. the system. i.e. whenever we type in localhost in the Address bar of any browser, it get redirected to

The simple technique behind blocking  a url using hosts file is by redirecting the typed url back to the system by just adding the following entries.           <url you want to block>

You can as much as url you need to add and can block any number of websites.

You can also redirect a typed url (mentioned earlier) but you will have to know the IP address to which the url have to be redirected. For that the entries to the hosts file should be as follows.

<IP address to which the url have to be redirected>          <url to be redirected>

using hosts file to hack

Hosts file can be used to launch a phishing attack in many cases. Some malicious software’s could rewrite the hosts file (Administrator rights are required to change any values in the hosts file, but viruses somehow manage to sneak through) so that some of the commonly typed URL will be redirected to their address where they have already hosted a phishing page to collect your personal data which they could use to hack you later.

, , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *