【问题标题】:Windows 10 hosts file not resolving any domains [closed]Windows 10主机文件不解析任何域[关闭]
【发布时间】:2018-04-22 18:11:04
【问题描述】:

我编辑了我的 hosts 文件以添加一个新的本地开发环境,从那时起它就无法工作,即使没有新条目也是如此。我虽然文件必须损坏所以我做了一个新的,仍然没有运气。

我已经确定使用了正确的语法,正确的编码(ANSI 也尝试了 UTF-8),没有 .txt 文件扩展名,没有奇怪的字符(在 notepad++ 上使用 show Characters)我什至尝试将其设置为尝试强制 Windows 使用它的系统文件,但这也不起作用。

我还刷新了 ipconfig dns,我尝试关闭 windows DNS 服务,重新启动。 它似乎被完全忽略了。

我大部分时间都在谷歌上,这让我很难过!

hosts 文件包含以下内容

127.0.0.1 ocommerce.test
127.0.0.1 www.ocommerce.test

就是这样。

我也试过了

127.0.0.1 ocommerce.test www.ocommerce.test

127.0.0.1    ocommerce.test www.ocommerce.test

ping 域时,我收到“Ping 请求找不到主机 ocommerce.test。请检查名称并重试。”

任何帮助将不胜感激。

编辑:

如果其他人即使在创建新文件后仍在努力解决此问题,请尝试复制此文件并将您的行添加到底部。 (这是我复制的,不知道为什么,但之后它就起作用了!)

# 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 handle within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

【问题讨论】:

  • 在资源管理器中打开显示文件扩展名并确保您的 Hosts 文件没有“.txt”扩展名。如果是,请将其删除。
  • @T.Heron 谢谢,但显示扩展名在那里,文件上没有扩展名,文件名为“hosts”
  • 好的,然后从另一台机器复制一个已知良好的文件,并确保仅使用 Windows 内置记事本编辑器或 Notepad++ 编辑新文件 - 不能使用其他任何东西。
  • 搞定了,可能需要原hosts文件中的一些cmet?或者即使在创建多个新文件后文件仍然损坏。不管怎样,谢谢!
  • 让我把它变成一个答案,一定要接受,因为它在人们将来搜索此类问题时显示为“绿色”。

标签: windows dns windows-10 virtualhost hosts


【解决方案1】:

创建一个新的文本文件并将主机文件的内容复制到新文件中。 然后删除现有的主机文件并将新文件重命名为主机文件(不需要扩展名)。这应该可以解决您的问题

【讨论】:

    【解决方案2】:

    从另一台机器上复制一个已知良好的文件,并确保仅使用 Windows 内置记事本编辑器或 Notepad++ 编辑新文件,而不是使用其他任何东西。

    【讨论】:

      猜你喜欢
      • 2019-10-08
      • 1970-01-01
      • 1970-01-01
      • 2016-02-07
      • 2011-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-18
      相关资源
      最近更新 更多