一、什么是Hosts文件? Hosts是一个没有扩展名的系统文件,Hosts文件是一个用于存储计算机网络中节点信息的文件,它可以将主机名映射到相应的IP地址,实现DNS的功能,它可以由计算机的用户进行控制。可以用记事本等工具打开,其作用就是将一些常用的网址域名与其对应的IP地址建立一个关联“数据库”,当用户在浏览器中输入一个需要登录的网址时,系统会首先自动从Hosts文件中寻找对应的IP地址,一旦找到,系统会立即打开对应网页,如果没有找到,则系统再会将网址提交DNS域名解析服务器进行IP地址的解析。 Hosts文件的存储位置在不同的操作系统中并不相同,甚至不同Windows版本的位置也不大一样: Windows NT/2000/XP/2003/Vista/win7:默认位置为%SystemRoot%system32driversetc,但也可以改变hosts文件位置: windows XP系统的位置:C:WINDOWSsystem32driversetc hosts 文件内容:
复制代码代码如下: # 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
复制代码代码如下: Windows 98系统,文件路径Windows目录下; Windows XP系统,文件路径WindowsSystem32DriversEtc目录下; Windows 2000系统,文件路径:WINNTSystem32DriversEtc目录下; WIN7系统,文件路径:WINNTSystem32DriversEtc目录下