如何通過電腦名稱訪問一台主機?

來源:互聯網
上載者:User
    這並不是一個新的文章,但前段時間由於工作需要遇到了這樣的問題。
    我們架設了一個網站,由於某些原因,只能通過電腦名稱(主機名稱)訪問這個網站,而不能通過IP地址訪問。
而有些時候,我們區域網路內的使用者是可以訪問的,但又有一部分使用者不能訪問。為此,我查閱了一些資料,發現了這個解決辦法。原來在C:\windows\system32\drivers\etc目錄下,有一個名為hosts的檔案。其內容如下: 1# Copyright (c) 1993-1999 Microsoft Corp.
 2#
 3# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
 4#
 5# This file contains the mappings of IP addresses to host names. Each
 6# entry should be kept on an individual line. The IP address should
 7# be placed in the first column followed by the corresponding host name.
 8# The IP address and the host name should be separated by at least one
 9# space.
10#
11# Additionally, comments (such as these) may be inserted on individual
12# lines or following the machine name denoted by a '#' symbol.
13#
14# For example:
15#
16#      102.54.94.97     rhino.acme.com          # source server
17#       38.25.63.10     x.acme.com              # x client host
18
19127.0.0.1       localhost

    我們看到,在最後一行的127.0.0.1 localhost. 前面是IP地址,後面就是對應這個IP的主機名稱。因此,現在我們訪問127.0.0.1和localhost都是訪問的本地主機。
    現在,我們在之後增加一行:1211.143.112.*   techserver

    現在我們就可以通過主機名稱techserver訪問IP地址為211.143.112.*的主機了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.