在此问题下粘贴的是/etc/hosts
来自Linux(CentOS)和Windows计算机的文件示例。Linux文件在IP地址(即localhost.localdomain localhost)之后有两个选项卡式条目,而Windows只有一个。如果要在Windows中编辑hosts文件以使用计算机名(etest)而不是localhost,则只需将localhost替换为所需的计算机名。机器不必是域的一部分。
在Linux机器,两个条目localhost.localdomain
,并localhost
似乎表明我需要的机器是一个域的一部分。这是真的?
我可以简单地将两个条目都编辑为etest
,以使其显示为:
127.0.0.1 etest etest
还是要求我用域名代替一个条目?
此外,请让我知道/etc/hosts
Linux计算机上文件的第二行是什么。
::1 localhost6.localdomain6 localhost6
hosts
Linux机器上的文件:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
hosts
Windows机器上的文件:
# Copyright (c) 1993-1999 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
127.0.0.1 localhost