Windows XP/2000/Vista/7/8/8.1/10系统 hosts文件位置及使用

Windows XP/2000/Vista/7/8/8.1/10系统的hosts文件的存储位置为C:\Windows\System32\drivers\etc下的hosts文件

用记事本可以直接打开编辑,或者用其他文本编辑器,比如EditPlus

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

hosts文件保存的是IP和域名的键值对,每一个键值对必须独立一行,每一行的第一个值为IP,第二个值为对应的域名,IP和域名之间必须至少有一个空格分隔

hosts文件中可以有注释,注释可以独立一行或者跟在IP域名键值对的后面,注释以#符号开头

如下所示,我们可以添加一些IP域名键值对

# For example:
102.54.94.97     rhino.acme.com          # source server
38.25.63.10      x.acme.com              # x client host

hosts文件有一个作用就是把域名重定向到错误的IP地址上,这样就无法正常防伪该域名,比如如下实例我们把account.jetbrains.com名重定向到0.0.0.0,这样本机就无法访问account.jetbrains.com。有些流氓程序经常会在后台偷偷访问一些地址上传或者下载一些东西,如果知道其域名就可以重定向到错误的IP,这样这些流氓软件就无法正常访问

0.0.0.0 account.jetbrains.com

 

posted @ 2020-01-05 13:41  野猿新一  阅读(101)  评论(0编辑  收藏  举报