วางด้านล่างคำถามนี้เป็นตัวอย่าง/etc/hostsไฟล์จาก Linux (CentOS) และเครื่อง Windows ไฟล์ Linux มีรายการแบบแท็บสองรายการหลังจากที่อยู่ IP (นั่นคือ localhost.localdomain localhost) และ Windows มีเพียงรายการเดียว หากฉันต้องการแก้ไขไฟล์โฮสต์ใน Windows ให้มีชื่อเครื่อง (etest) แทน localhost ฉันเพียงแทนที่ word 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