1

Problem

I’m seeing a strange and extremely frustrating problem.

Any system that is not connect to the Internet (Windows 7 shows the no Internet access icon because it cannot constantly ping Microsoft’s servers) cannot even access locally hosted servers.

Hypothesis

The problem appears to be that the HOSTS file is not being used to resolve DNS entries when there are no active NICs.

Tests / Reproduction

You can reproduce it as so:

  1. Disconnect a system from the Internet (make sure all wired and wireless connections are disconnected).

  2. If necessary, add an entry to the HOSTS file (e.g., 127.0.0.1 foobar or 127.0.0.1 foobar.com)

  3. Open a command-prompt

  4. Type ping foobar or ping foobar.com

Observations

The screenshots below show a clear and demonstrative example. In the first snap, a laptop is connected to a router wirelessly. The HOSTS file has only three entries and they resolve just fine. In the second snap, the wireless radio is turned off, so the entries in the HOSTS file are ignored. Moreover, notice that pinging localhost still works even without any active NICs (as does 127.0.0.1), but it is using the IPv6 address (must be hard-coded).

You can see the same results in Windows XP with no IPv6 installed, so it has nothing to do with IPv6. I tried pining what should have resolved to 127.0.0.1 while the desktop system (with no wireless NICs) was connected via its Ethernet adapter, then again after pulling the cable from the router and waiting a couple of seconds, then again after plugging the cable back in. The same thing happens if instead of pulling out the cable, the NIC is disabled through software (the [Disable] button in the NIC’s Status dialog or via Device Manager).

Conclusions

It looks as though the HOSTS file is only being read and used if there is an active NIC, otherwise it is being ignored. This makes some sense in that if there are no active network adapters, then presumably there will not be any network activity, and thus no need to resolve host names via the HOSTS file.

This assumption is specious however because it precludes locally hosted virtual servers. The HOSTS file should be used regardless of external DNS server connectivity, otherwise you cannot use simple/consistent/testing-production names for locally hosted servers when not connected to the Internet (for example web servers; help servers for Visual Studio, 3dsmax, etc.; and so on).

Question

Does anyone know how to force Windows to use the HOSTS file even if there are no active NICs?


Appendix

Figure 1: While the wireless NIC is connected to the router (the cable-modem is in standby, so no external Internet connectivity).

Connected

Figure 2: With the wireless radio turned off (the Ethernet port is not unconnected in both cases).

Not connected

Figure 3: Same results in XP with no IPv6

XP with no IPv6

10
  • Are there any proxies involved in your network or is your browser configured to use a proxy?
    – duenni
    Mar 18, 2013 at 9:26
  • @duenni, No.​​​
    – Synetech
    Mar 23, 2013 at 16:42
  • I have re-written the question to clarify the underlying issue. It is NOT off-topic or localized, it appears to be an issue with Windows using the HOSTS file.
    – Synetech
    Mar 23, 2013 at 16:42
  • It appears to be some weird bug in Win7. Here's a link, check if it works fo you
    – pupkinsen
    Mar 23, 2013 at 18:15
  • @pupkinsen, hmm, I think it also happened in XP, but that link looks promising. It’s the weekend right now, but I’ll try it out first thing Monday. ☺
    – Synetech
    Mar 24, 2013 at 0:37

2 Answers 2

1

Did you try to check if these host names are resolved correctly with ping or something? That could help in locating the problem. If they are then it is most likely to be the problem that MDMarra described.

1
  • Actually I did. That’s how I figured out the underlying issue. I have rewritten the question to clarify the problem.
    – Synetech
    Mar 23, 2013 at 16:43
0

Most likely you have a service or services binding to an address or interface that is no longer "up" when you've disconnected the cable. Check your config files.

2
  • I’m not sure what you mean. For example Apache binds to an IP address or hostname. If it’s binding to a hostname, shouldn’t the HOSTS file cause it to resolve to 127.0.0.1 even if no external IP is found? If it is binding to 0.0.0.0 (which is my case), then why would require an external connection?
    – Synetech
    Mar 16, 2013 at 16:32
  • It has nothing to do with config files because the host name does not resolve at all.
    – Synetech
    Mar 23, 2013 at 16:43

Not the answer you're looking for? Browse other questions tagged .