   
- 帖子
- 618
- 积分
- 1888
- 威望
- 2421
- 金钱
- 2970
- 在线时间
- 179 小时
        
|
一、什么是hosts文件
hosts文件存在于Windows目录下的system32\drivers\etc中。这个文件没有扩展名,但是,我们可以使用记事本来打开编辑。打开文件,可以看见其中有很多英文解释,在文件末尾,有127.0.0.1localhost这一行字。这个文件包括主机的IP地址和映像名称,输入的每一个地址都应该放在单独的行列中。IP地址应该被放在对应的主机名的第一栏中。IP地址与主机名之间应该至少有一个空格。
由于我们在访问网站时,对hosts文件的请求级别比DNS服务器高,因此修改hosts文件可以对指定的网址进行处理,达到防止用户访问特定网站的效果。
hosts文件还可以加快我们对网站的访问速度。在我们访问网络的时候,我们的计算机向DNS服务器发送一个网络域名,DNS服务器则把这个域名解析成为一个IP地址后返回给计算机。这个过程会使访问网站的速度减慢。正确地对hosts文件进行编辑可以加快对网站的访问速度。如:在hosts文件中添加指定的IP地址,使得DNS服务器不用对网页的地址进行解析。
其实,hosts文件还有其他的特殊高级功能:如方便局域网用户顺利连接系统等。这些功能可以大大减少我们对网络的访问时间,使我们对网络的访问更快捷、更方便。
二、屏蔽特定网站
要屏蔽特定网站,我们可以如下操作。
1.在C:\windows\system32\drivers\etc中,找到hosts文件,用记事本打开。
2.在文件的最下方输入你要屏蔽的几个网站的地址,格式如下假设要屏蔽的网址为my123***.com:
127.0.0.1 www.my123***.com
127.0.0.1 my123***.com
3.保存hosts文件。
4.将hosts文件的属性改为只读,防止被病毒篡改。
三、加速访问网站
要加快网址的解析速度,为我们访问网站提速,先要查找你所需要访问的网站的IP地址,可以使用ping命令。然后,打开hosts文件,在文件的末尾加上“IP地址域名”。
最后,保存hosts文件并修改为只读属性。当你再次浏览该网站时,域名—IP地址的解析工作就由你本机完成了,不需要访问DNS服务器,加快了网站访问速度。
来源:互联网 |
|