码迷,mamicode.com
首页 > Windows程序 > 详细

windows hosts 作用以及常见问题解决

时间:2015-05-03 15:58:46      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

借用百度百科的解释

  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.1	sn.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 作用以及常见问题解决

标签:

原文地址:http://www.cnblogs.com/sesna/p/host_troubleshot.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!