windows hosts 作用以及常見問題解決

來源:互聯網
上載者:User

標籤:

借用百度百科的解釋

  Hosts是一個沒有副檔名的系統檔案,可以用記事本等工具開啟,其作用就是將一些常用的網址網域名稱與其對應的IP地址建立一個關聯“資料庫”,當使用者在瀏覽器中輸入一個需要登入的網址時,系統會首先自動從Hosts檔案中尋找對應的IP地址,一旦找到,系統會立即開啟對應網頁,如果沒有找到,則系統會再將網址提交DNS網域名稱解析伺服器進行IP地址的解析。

  更詳細的說明:http://baike.baidu.com/link?url=uwQLcpconowLlQZII12bLU58-5uT_4qX5UOCz_Gr45ACo6CYyTCL4q-8VkZW4BxEsJzAVMBXyW6J8A2fEbwab_

 

檔案位置

C:\Windows\System32\Drivers\etc\hosts

內容

# 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

檔案裡面已經說得很清晰了,主要的一點,添加ip跟網域名稱的時候至少要有一個空格隔開。

比如添加一個網域名稱,指向本機,個人習慣用tab分隔。

127.0.0.1sn.cn

測試是否生效,開啟命令列,ping

 

常見問題

  1、沒有許可權修改hosts檔案:http://jingyan.baidu.com/article/ab69b270d963542ca6189f75.html

  2、修改之後不生效,可能原因

    1). dns緩衝沒重新整理

    

    

    2). dnsclient服務影響,原因看windows自己的說明,關了就行了,再不行禁用。也不影響其它功能。比較快的啟動方式:運行services.msc

      

 

    3). 360等安全軟體把hosts檔案鎖定了,在360面板的功能大全找到流量防火牆,修複它,這個問題印象很深刻,不解決的話前面的操作都沒用。

          

 

windows hosts 作用以及常見問題解決

聯繫我們

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