开发者

internet explorer on windows virtual machine is ignoring my hosts file

i'm running xp as a virtual machine on windows7 so that i can check what websites look like in ie 6 & 7 that i am building locally, on the same machine.

internet explorer will not find any page hosted on the loalhost. "Internet Explorer cannot display the webpage." i can put an ip address to another server on my lan, and that works fine, but if it is on the same machine, it refuses.

there is no proxy.

i have turn开发者_JAVA百科ed DNS Client Service on and off lotsa times, no effect.

can anybody help?

EDIT: my virtual machine's hosts file had lines like: 127.0.0.1 mydomain.dev


thank you, nos and Andrew, you both helped me realize that i wasn't treating the virtual machine as it's own machine. my host file had lines like

127.0.0.1 mydomain.dev

which is perfectly valid, but it points to the virtual machine (where there is no web server sw). this is my first time using virtual machines, and i was just so used to my hosts file using 127.0.0.1 for my dev sites. what i needed was to use the ip address of the windows7 machine (where apache is running) instead:

192.168.1.42 mydomain.dev

i'm sure one of you would have seen my error if i hadn't been so sure of my hosts file. thanks! i hope this helps someone else!


If you mean localhost as in your Windows 7 machine it sounds like you are not using Bridge networking. That means your virtual machine can get to the outside but cannot see your local 192.168.* subnet.

Do this within your windows 7 in a command prompt

ipconfig /all

And this in your Windows XP

ipconfig /all

You'll probably get something like this on your windows 7 machine

(NIC) 192.168.1.100

Virtual-Box 192.168.10.100

and something like this on your windows xp

(NIC) 192.168.10.101

I suspect that your virtual machine is on a different subnet than your main computers NIC.

All hope isn't lost you can

  • Change your VM network bindings to bridged mode

  • or use the ip address that is in the same subject on your windows 7 machine as your Windows xp and ensure your web server is bound to 0.0.0.0 (all interfaces).

If you are trying to access the web server running on your windows 7 machine as 192.168.1.100 from your windows xp, you'll just change it to 192.168.10.100. Keep in mind I made up all these ip addresses and you'll need to change it to your own.


try the link 1, I had a similar problem and I took the effort to document it, I have not found this solution after looking for a few minutes.

Basically you have the go to your LAN settings of your internet explorer browser and disable automatic configuration. Don't worry this setting affects other browser as well.


Windows XP has to be rebooted for host files settings to apply to Internet Explorer.


I ran into the same problem sometime back.

In IE10 and IE11 protected mode is always on by default. Add the URL to the trusted sites at the security tab of Internet Explorer settings. Uncheck SSL check box if site is running on http protocol only.

Also with Windows 8.1, unchecking "Automatically detect settings" at the LAN settings (connection tab) will enable custom entries in the HOSTS file.

This should fix the issue.


a 'quick' way to add host to your hosts file with the host machine's IP address so you can visit http://host:<port>/<path> inside your vm:

  1. In the the VM open an administrator console (Win, "cmd", CTRL+SHIFT+ENTER)

  2. run "CMD /f:off" (which allows pasting tab characters)

  3. Paste the following into cmd

    reg query "HKEY_CURRENT_USER\Volatile Environment\1" /v CLIENTNAME | more +2 > %TEMP%\clientname.txt & set /P regclientname=<%TEMP%\clientname.txt & call set CLIENTNAME=%regclientname:~28% & call echo %CLIENTNAME% & call nslookup %CLIENTNAME% | more +4 > %TEMP%\addr.txt & SET /P ADDR=<%TEMP%\addr.txt & call set HOSTIP=%ADDR:~10% & call echo %HOSTIP% & set HF=C:\windows\System32\drivers\etc\hosts && echo.>>%HF% && echo.>>%HF% && call echo  %HOSTIP%   host >>%HF% && type %HF%
    

NB: the extra "call" prefixes are so it picks up the variables set previously. It has to get CLIENTNAME from the registry as that is only set as a variable in unelevated sessions.


Alternatively!

  1. Win
  2. http://%CLIENTNAME%/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜