百味木屋

          --點點滴滴,油鹽醬醋
          隨筆 - 5, 文章 - 0, 評論 - 0, 引用 - 0
          數據加載中……

          localhost與127.0.0.1

             在沒有網絡的情況下,在命令行ping localhost與ping 127.0.0.1也是可以ping通的(前提需有網卡),但兩者有到底有區別嗎?有聯系嗎?
          我現在的理解是localhost是127.0.0.1的一個別名,兩者是通過C:\WINDOWS\system32\drivers\etc\hosts(在此假定系統盤為C盤)這個文件來對應起來的。用記事本打開這個文件,內容如下:
          # 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
          在這個文件的最后一行寫明了127.0.0.1與localhost的對應關系,我們不防來做個實驗,在這個文件最后加下面一行:
          127.0.0.1   happy
          保存之后,再打開命令行,ping happy,你會發現,現在happy也可以ping 通了,由此可知localhost只是大家約定的代表127.0.0.1的一個別名,如果你喜歡,你可以通過上面這種方式為127.0.0.1配置不同的別名。

          posted on 2008-10-03 22:45 文濤 閱讀(1762) 評論(0)  編輯  收藏 所屬分類: NetWork


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 称多县| 西畴县| 龙泉市| 长丰县| 清河县| 七台河市| 苏尼特右旗| 宜丰县| 元江| 金阳县| 榆树市| 和政县| 通城县| 宁夏| 和林格尔县| 儋州市| 百色市| 临泽县| 平乡县| 抚宁县| 庐江县| 鹿邑县| 即墨市| 平乐县| 宁波市| 克东县| 海淀区| 大名县| 鲁山县| 沧源| 东乡族自治县| 宣化县| 福鼎市| 营口市| 贵德县| 通榆县| 安吉县| 屯昌县| 平塘县| 乐都县| 密云县|