百味木屋

          --點點滴滴,油鹽醬醋
          隨筆 - 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 文濤 閱讀(1766) 評論(0)  編輯  收藏 所屬分類: NetWork


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


          網站導航:
           
          主站蜘蛛池模板: 定边县| 八宿县| 沙河市| 成都市| 合阳县| 桓台县| 南溪县| 安远县| 赤水市| 龙山县| 碌曲县| 延庆县| 社会| 青海省| 高州市| 湘潭县| 长乐市| 武川县| 寻甸| 贵州省| 兰考县| 微博| 潞西市| 大埔县| 翁牛特旗| 临洮县| 揭阳市| 凤山市| 茌平县| 康定县| 屯门区| 嘉祥县| 临澧县| 六盘水市| 东光县| 安平县| 古交市| 辽源市| 盘山县| 新河县| 长治县|