百味木屋

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

          localhost與127.0.0.1

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

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


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 新民市| 昌邑市| 宜城市| 屏东市| 长兴县| 土默特左旗| 阜阳市| 五峰| 诸暨市| 曲靖市| 霞浦县| 莱芜市| 辛集市| 揭西县| 兴文县| 德江县| 马边| 育儿| 呼伦贝尔市| 泰宁县| 枞阳县| 虞城县| 佛山市| 齐齐哈尔市| 丽水市| 屯门区| 石泉县| 揭阳市| 垣曲县| 泾川县| 内黄县| 广灵县| 美姑县| 博爱县| 深水埗区| 龙南县| 连平县| 青河县| 海伦市| 天水市| 宜宾市|