我的主机文件 C:\Windows\System32\drivers\etc

我的主机文件 C:\Windows\System32\drivers\etc

前几天我发布了这个问题https://stackoverflow.com/questions/7519360/urls-are-inconsistently-being-redirected-using-isapi-urlrewrite-3-0

我在笔记本电脑上进行一些本地开发测试,然后出现了一些普遍的怪异现象(如超链接问题中所示)。现在问题似乎更大了。我甚至在本地关闭了 IIS。但当我输入“localhost”时,系统仍会将我发送到 www.sc-pa.com。但是,当 IIS 仍在运行时,如果我输入“localhost/default.asp”,它确实有效。我尝试过 ping localhost,似乎没问题。我试过 tracert。我知道的唯一可能造成问题的本地操作是将 dns 后缀添加到我的连接中。除此之外,我无法理解这是怎么发生的。

当我的本地 IIS 运行时输入“localhost”,其日志甚至不会被触及。

我的主机文件 C:\Windows\System32\drivers\etc

该文件的修改日期为 2009 年 6 月 10 日,我绝对不会修改它。这对我来说很正常。

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

从 nslookup localhost 更新视图

在此处输入图片描述

更新 #2

我已经将问题归结为 IE8。Chrome 和 Firefox 确实将 localhost 解析为我的本地计算机。我尝试重置 IE8 中的所有设置,但没有帮助。我甚至连接到另一个无线网络并尝试。

答案1

您是否尝试取消注释主机文件中的 IPv4 本地主机条目?

#   127.0.0.1       localhost

这里的一些答案提供了有关为什么这种情况会发生在 Vista 及更高版本的操作系统上的更多详细信息,但据我了解,根本原因与 MS 决定实施 DNS 解析的方式有关,特别是 IPv6:https://stackoverflow.com/questions/1416128/my-local-host-goes-so-slow-now-that-i-am-on-windows-7-and-asp-net-mvc

和:

Windows 7:“本地主机名称解析由 DNS 本身处理”。为什么?

Windows 将首先尝试在主机文件中查找,然后如果未找到合适的条目则尝试名称服务器。

因此,由于主机文件中没有 localhost 的条目,因此需要由名称服务器来解析 localhost。

一种可能性是,名称服务器将 localhost 解析为您的自身而不是您的机器,并给出重定向的外观。

答案2

在命令行中输入ping localhost,如果它没有返回127.0.0.1,则表示::1您遇到了问题。

nslookup localhost可能会或可能不会给您“不存在的域”。

相关内容