开发服务器的 Windows Hosts 文件条目

开发服务器的 Windows Hosts 文件条目

我有一个 IP 地址,在开发域名期间暂时不想分配给它。但是我希望我的客户能够通过其他方式访问网站,而不是输入地址。我研究了如何更改客户的主机文件,并尝试在我的 (Wind 8) PC 上进行操作。但是名称无法解析,chrome 返回未找到错误。

如果最终我无法实现我想要的结果,我还有其他类似的选项来创建 IP 地址的文本快捷方式吗?

我在创建快捷方式时发现了这个概念:

http://www.makeuseof.com/tag/6-surprising-uses-for-the-windows-hosts-file/

这是我的主机文件,我做错了什么?

# 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
    XXX.XX.XXX  app-dev     # app dev server

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

在浏览器中输入:app-dev/

并且 chrome 返回未找到错误。

答案1

由于系统未加入域,因此您可能必须使用 WINS 仅通过名称访问服务器。如果您想查看计算机认为该地址是什么,请使用以下命令

PING -A xxx.xxx.xxx.xxx  

当然,其中的 X 代表 IP 地址。

然后,您将看到系统所看到的机器的完全限定名称,并且应该能够通过该名称访问它。

您可以尝试将名称放入 LMHOSTS 而不是 HOStS,并确保在 TCP/IP - IPV4 的高级设置中启用了 NETBIOS。适配器设置 → 属性 → TCP/IP v4 → 属性 → 高级按钮 → WINS 选项卡:选择“启用 LMHOSTS 查找”和“默认”。

本质上,DNS 查找失败是因为它不在您的域中,因此您使用 LMHOSTS + WINS 让您的系统能够找到它。

相关内容