Thursday, April 7, 2011

How do I change my hosts file & What is a hosts file?

What is a HOSTS file?

The Hosts file contains the mappings of IP addresses to host names. This file is loaded into memory (cache) at startup, then Windows checks the Hosts file before it queries any DNS servers, which enables it to override addresses in the DNS. This prevents access to the listed sites by redirecting any connection attempts back to the local (your) machine.

*** SIMPLE VERSION:  The HOSTS file has the ability to block web sites & other applications from connecting to the Internet, providing the entry exists.***


HOW TO EDIT

1) Edit your hosts file on your PC.

For Windows 7

To access the hosts file in Windows 7 you can use the following command in the Run Line to open notepad and the file.
notepad c:\windows\system32\drivers\etc\hosts



Then open the file for editting with Notepad. There should already be an entry for "localhost". Follow that format when you insert your domain and our IP.

  In Windows 7, the entry order is 'IP address' then 'hostname'


          127.0.0.1 localhost
          127.0.0.1 www.facebook.com

Then save this altered hosts file and close notepad. Make sure Windows did not silently save the file as "hosts.sam". The filename has to be "hosts". You may also need to reboot for the change to take effect. Next time you try to go to "127.0.0.1 www.facebook.com", your browser will try to find that domain at the corresponding IP instead of looking up the IP through DNS.
  • Windows 7 - Example of HOSTS file in Action

    To access the hosts file in Windows 7 you can use the following command in the Run Line to open notepad and the file.
    notepad c:\windows\system32\drivers\etc\hosts


    Once notepad is open you can edit the file. In this example we will block Facebook. To do this just enter in the following after the # mark.
    0.0.0.0    www.facebook.com
                                   OR
              
             127.0.0.1    www.facebook.com



    Now that you have edited your Hosts file make sure to save it.



    Now try to access Facebook.com in Google Chrome… This is a perfect example of a HOSTS file doing it's job.

    Using the same method above can also block any application from searching the internet for updates. 

    So for example... There is a program called DU Meter.  It shows you, and keeps a record, of just how fast the download & upload rate of your internet connection is.  It's a very handy app for those of you who either do a lot of downloading, or just want to see if there is any apps using the internet "behind the scenes" without your knowledge.

    Lets say, for instance, you don't want it automatically updating in the background with out your knowledge....  Here is an example of what to enter into your hosts file to stop the app from updating all-together.

    127.0.0.1 www.dumeter.com
    127.0.0.1 dumeter.com
    127.0.0.1 www.hageltech.com
    127.0.0.1 hageltech.com



     

No comments:

Post a Comment