Windows Host 檔案

來源:互聯網
上載者:User

什麼是Host檔案?

===================

簡單的答案就是: host檔案就像一個地址本. 當你在你的瀏覽器中鍵入一個網址的時候, host檔案會被查詢到, 看你是否已經為那個網站設定了IP地址. 如果你設定了, 那麼你的電腦會用這個IP去開啟網站. 如果沒有, 那麼電腦回去查詢你的internet service provider(ISP)的電腦去尋找IP地址. 多數的時候, 在host檔案中不會有那些IP. 所以多數時候, 電腦會去查詢ISP來獲得IP地址.

 

長一點的答案是: Windows和其他動作系統使用host檔案來將主機名稱與IP地址對應起來.

 

尋找與主機名稱對應的IP需要一系列的步驟:

先查詢你原生host檔案. host檔案會告訴你的電腦主機名稱對應的IP地址, 這樣你的電腦就會停止查詢, 直接開啟網站. 但是如果它沒找到, 它就會去詢問DNS伺服器(domain name server), 索要資訊.

 

Host檔案的位置

===================

Windows 95/98/Me

              c:\windows\hosts

Windows NT/2000/XP Pro

              c:\winnt\system32\drivers\etc\hosts

Windows XP Home / Windows 7/ Windows Server 2008

              c:\windows\system32\drivers\etc\hosts

 

注意:

Host是檔案的名字而不是檔案夾的名字. 這個檔案沒有副檔名(比如說.exe, .txt, .doc等等)

 

如果你沒有host檔案, 你可以自己建立一個, 把它放到上面例舉的檔案夾中.

 

注意:

如果你發現你已經有了host檔案, 我推薦你把它備份一個, 拷貝到另外的一個硬碟分區上, 這樣你就可以恢複了.

 

Host檔案舉例

# 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        alternative80

 

 

http://accs-net.com/hosts/what_is_hosts.html

http://accs-net.com/hosts/how_to_use_hosts.html

http://en.wikipedia.org/wiki/Hosts_file

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.