共用方式為

Windows 7 的 hosts file 為何 localhost 變為註解狀態,卻還是能使用?

匿名
2010-04-26T06:35:14+00:00

大家好,Windows 7 的 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

localhost name resolution is handled within DNS itself.

#    127.0.0.1       localhost

#    ::1             localhost

照理說,# 號後方的文字,應該是當做註解。

因此最後兩行

#    127.0.0.1       localhost

#    ::1             localhost

應該是沒效的,但為在命令提示字元中 ping localhost 但仍可以得到下面的結果:

C:>ping localhost

Ping computername [::1] (使用 32 位元組的資料):

回覆自 ::1: time<1ms

回覆自 ::1: time<1ms

回覆自 ::1: time<1ms

回覆自 ::1: time<1ms

可以麻煩專家們,說明一下原理嗎?

Windows for home | 舊版 Windows 版本 | Windows Update

鎖定的問題。 此問題已從 Microsoft 支援服務社群移轉。 您可以對其是否有幫助進行投票,但無法對問題新增註解或回覆,或進行追蹤。

0 則留言 沒有留言

9 個其他答案

排序依據: 最實用
  1. 匿名
    2010-04-27T01:56:12+00:00

    另外一個讓人不解的一個結果:

    C:&gt;ping localhost

    Ping computername [::1] (使用 32 位元組的資料):

    回覆自 ::1: time<1ms

    ::1 的 Ping 統計資料:

        封包: 已傳送 = 1,已收到 = 1, 已遺失 = 0 (0% 遺失),

    大約的來回時間 (毫秒):

        最小值 = 0ms,最大值 = 0ms,平均 = 0ms

    正常的應該會進行 4 次,但您的結果卻僅有 1 次


    論壇 問卷大調查,讓您票選論壇 MVP

    此回答有幫助嗎?

    0 則留言 沒有留言
  2. 匿名
    2010-04-27T01:47:52+00:00

    使用 Bing 翻譯 localhost name resolution is handle within DNS itself 的結果為:

    本地主機名稱稱解析是在本身的 DNS 內處理

    該 Windows 7 電腦沒設定網路卡的 IP 位址、預設閘道、DNS ... 等嗎?

    若沒設定 DNS,理論上,執行 nslookup localhost 的結果應該會出現類似下面的結果:

    DNS request timed out.

         timeout was 2 secondds.

    伺服器:  UnKnown

    Address:  fec0:0:0:ffff::1

    DNS request timed out.

         timeout was 2 secondds.

    DNS request timed out.

         timeout was 2 secondds.

    *** 對 UnKnown 的要求逾時

    方便的話,請貼 ipconfig /all 的資料。


    論壇 問卷大調查,讓您票選論壇 MVP

    此回答有幫助嗎?

    0 則留言 沒有留言
  3. 匿名
    2010-04-27T01:32:36+00:00

    Dear Alex ,

    這是在下的疑問,

    localhost name resolution is handle within DNS itself

    這是表示說 DNS server 會負責幫忙解析嗎? 但...就沒有本機就沒架 DNS server 啊... (我沒設定 DNS server 的 IP)

    而且網路是未連線的狀態..

    這是 ping 及 nslookup

    C:&gt;ping localhost

    Ping computername [::1] (使用 32 位元組的資料):

    回覆自 ::1: time<1ms

    ::1 的 Ping 統計資料:

        封包: 已傳送 = 1,已收到 = 1, 已遺失 = 0 (0% 遺失),

    大約的來回時間 (毫秒):

        最小值 = 0ms,最大值 = 0ms,平均 = 0ms

    C:&gt;nslookup localhost

    伺服器:  UnKnown

    Address:  fec0:0:0:ffff::1

    *** UnKnown 找不到 localhost: No response from server

    這個真的是讓小弟不解的一個結果...

    此回答有幫助嗎?

    0 則留言 沒有留言
  4. 匿名
    2010-04-27T00:35:01+00:00

    註解已經有說明了:

    localhost name resolution is handle within DNS itself您可以開啟「命令提示字元」,輸入下列指令,並按下 Enter 鍵:

    nslookup localhost

    看看輸出的結果為何


    論壇 問卷大調查,讓您票選論壇 MVP

    此回答有幫助嗎?

    0 則留言 沒有留言