电脑常识——host文件修改(屏蔽网站或解开屏蔽)

 

来源:https://blog.csdn.net/double12754/article/details/88407132

 

1. 什么是host文件:

Hosts文件主要作用是定义IP地址和主机名的映射关系,是一个映射IP地址和主机名的规定。可以用文本文件打开!当用户在浏览器中输入一个需要登录的网址时,系统会首先自动从Hosts文件中寻找对应的IP地址,一旦找到,浏览器会立即打开对应网页,如果没有找到,则浏览器会将网址提交远程的DNS服务器进行IP地址解析。即:host文件可以提高我们加载网页的速度。

2. 修改host文件有什么用?

比如我们要把www.xxx.com屏蔽掉,我们只需要这样修改即可。
127.0.0.1 www.xxx.com #注释
(注意:127.0.0.1和网址之间留下一个空格,网址和#注释之间留下一个空格,还不懂可以参考电脑自带屏蔽网址的格式)
另外需要注意的是注意,IP地址前面不要有空格,ip地址和域名之间,要有至少1个空格。修改后,一定要记得保存文件,如果装有360安全卫士会提示是否禁止修改hosts文件,我们一定要选择允许,否则会修改失败。还有就是写完一个网址一定要回车换行才会生效,一行只可以屏蔽一个网址,建议这样修改:“ip地址+空格+域名+回车”来修改记录!

3. 如何找到host文件?

同时按Windows键(就是电脑fn键和alt键之间的那个四方形)+R
然后在跳出来的运行窗输入如下代码:
c:\windows\system32\drivers\etc
第一个就是hosts文件,之后右键用记事本打开
在host文件最下方可以看到如下形式的几行代码:

4.如何修改host文件:
屏蔽网址:127.0.0.1和0.0.0.0之后的网址都是被屏蔽了的,https网址用0.0.0.0去屏蔽
加快浏览网址的速度:网址IP 网址
例:104.193.88.77 www.baidu.com
(IP地址请自行ping,因为我们的网络不一样)
如何ping网址呢?
同时按Windows+R,输入cmd,确认;
出现一个黑色的界面,输入ping www.baidu.com(ping和网址中间有一个空格)

# 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 local.id.seewo.com

127.0.0.1 genuine.microsoft.com
127.0.0.1 mpa.one.microsoft.com
127.0.0.1 sls.microsoft.com

 

posted on 2021-04-23 09:02  华山青竹  阅读(2547)  评论(0编辑  收藏  举报

导航