Hosts file in Windows 7 screwed up!

2

I recently changed my Hosts file to block some websites in Windows 7. Now I think it is blocking lot of other sites that were not added to Hosts file. Is there any way to escape this?

I tried to replace it with some fresh Hosts file I found online but it doesn't change anything. Some sites are redirected to IIS7. What am I doing wrong?

Lalith

Posted 2010-12-30T17:44:14.877

Reputation: 125

Can you post a sample of some of the host file entries? It would be easier to figure out what went wrong if we could see the file. – Ed Manet – 2010-12-30T17:46:46.293

Answers

6

The actual location is defined by the following Registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath

There is no need to turn on, adjust or change any settings with the exception of the DNS Client service (see below). Windows automatically looks for the existence of a HOSTS file and if found, checks the HOSTS file first for entries to the web page you just requested. The 127.0.0.1 is considered the location of your computer, so when the entry (example) "ad.doubleclick.net" is requested your computer thinks 127.0.0.1 is the location of the file. When this file is not located it skips onto the next file and thus the ad server is blocked from loading the banner, cookie, or some unscrupulous ActiveX, or JavaScript file.

In case you're wondering, this all happens in microseconds, which is much faster than trying to fetch a file from half way around the world. Another great feature of the HOSTS file is that it is a two-way file, meaning if some parasite does get into your system (usually bundled with other products) the culprit can not get out (call home) as long as the necessary entries exist. This is why it's important to keep your HOSTS file up to date.

In most cases a large HOSTS file (over 135 kb) tends to slow down the machine.

To resolve this issue (manually) open the "Services Editor":

  1. Start > Run > (type) services.msc
  2. Scroll down to "DNS Client", Right-click and select: Properties - click Stop
  3. Click the drop-down arrow for "Startup type"
  4. Select: Manual (recommended) or Disabled
  5. Click Apply/OK and restart

When set to Manual you can see that the above "Service" is not needed (after a little browsing - when set to Manual) by opening the Services Editor again, scroll down to DNS Client and check the "Status" column. It should be blank; if it was needed it would show "Started" in that column.

A better Windows 7/Vista workaround would be to add two registry entries to control the amount of time the DNS cache is saved.

  1. Flush the existing DNS cache
  2. Start > Run (type) regedit
  3. Navigate to the following location:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters
    
  4. Click Edit > New > DWORD Value (type) MaxCacheTtl
  5. Click Edit > New > DWORD Value (type) MaxNegativeCacheTtl
  6. Next right-click on the MaxCacheTtl entry (right pane) and select: Modify and change the value to 1
  7. The MaxNegativeCacheTtl entry should already have a value of 0 (leave it that way - see screenshot)
  8. Close Regedit and reboot
  9. As usual you should always backup your registry before editing; see Regedit Help under "Exporting Registry files"

NaV

Posted 2010-12-30T17:44:14.877

Reputation: 202

Edited to switch to blockquote style so this wouldn't break horizontal scroll. @NaV, I'm assuming this was quote style because you are in fact quoting it - you should make an edit and add your source for further info. – Shinrai – 2010-12-30T19:06:46.327