Hosts File

Discussion in 'Software' started by aravind, Feb 13, 2011.

  1. aravind

    aravind Private E-2

    Hi,
    I'm having a peculiar problem. I tried to block an adult site by adding it's host name to the hosts file in Windows 7 PC and yet the site opens as before.
    I cleared by browser cache and even did a reboot to no avail.
    Please suggest.....
     
  2. shnerdly

    shnerdly MajorGeek

    You didn't describe how you added it it to the hosts file so I'll offer generic advice.

    The hosts file is in the c:\windows\system32\drivers\etc folder.

    You need to modify the file as Administrator in Win7.

    the entry would look like this:

    127.0.0.1 www.thesitetoblock.com
    127.0.0.1 thesitetoblock.com

    I also turn off the DNSclient service on all of my computers. If your hosts file is large, it will speed up internet access. My hosts file has 16,000 entries. This makes a significant difference in internet access times.
     
  3. aravind

    aravind Private E-2

    Hi shnerdly,
    Thanks for the reply.
    I used to edit Hosts file comfortably in Windows XP with the desired result.
    I ran Notepad as Administrator and opened the Hosts file and edited accordingly. But still I'm not able to block sites. I have a copy of this file uploaded for your perusal.
    I'd also like to know if turning off DNS Client service on computers cause any glitches.
    Thank You
     

    Attached Files:

  4. Earthling

    Earthling Interplanetary Geek

    My understanding is that turning that service off effectively disables the HOSTS file
     
    Last edited: Feb 16, 2011
  5. shnerdly

    shnerdly MajorGeek

    When you have the DNS Client enabled, it caches all the websites you visit and compares all requests to the cache and also compares the cache to the hosts file. If the DNS Client is off, all internet requests only look at the hosts file before going to an internet DNS Server. This will speed up your access if your hosts file is large.

    To turn it off temporarily, type "net stop dnscache" at the command prompt.

    Your hosts file has errors.

    The line 127.0.0.1 localhost must be enabled, you have it commented out. Thats what tells it to loop back to your computer when you direct a website there. Right now it doesn't know where to go for 127.0.0.1 so it ignores it.

    Also the last two line are invalid. You can't add anything after the .com, .org, .net etc. and you can't have the http:// in any of the entries.

    your file should be

    127.0.0.1 localhost
    ::1 localhost
    127.0.0.1 www.whatever.com
    127.0.0.1 whatever.com

    The second line above is for IPv6. Not really important just yet but it will be in the future so I would leave it.

    That will block all of whatever.com unless they have some subdomains like visit.whatever.com or apps.whatever.com in which case you need to add them as well.
     
    Last edited: Feb 17, 2011
  6. aravind

    aravind Private E-2

    Hi shnerdly,
    Many thanks for the guidance.
    I'm able to fully control the undesired sites now.
    Thanks again
     
  7. shnerdly

    shnerdly MajorGeek

    Using Robin Williams words when he played the immortal Andrew, "One is glad to be of service"
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds