摘要
本文帮助你将主机文件重置回默认值。
什么是 Hosts 文件
操作系统使用 Hosts 文件将用户友好的主机名映射到数字 Internet 协议 (IP) 地址,用于标识和定位 IP 网络中的主机。 hosts 文件是用于处理计算机网络中网络节点的多个系统资源之一,是操作系统 IP 实现的常见部分。
Hosts 文件包含文本行,由第一个文本字段中的 IP 地址组成,后跟一个或多个主机名。 每个字段都用空格分隔 (出于历史原因,通常首选选项卡,但空格也) 使用。 注释行可能包含在内,它们由哈希字符 (#) 在此类行的第一个位置指示。 文件中的完全空白行将被忽略。如果主机文件已从默认值更改,则重置该文件有助于解决某些连接问题。
解决方法
若要将主机文件重置回默认值,请根据你的操作系统执行以下步骤:
若要将主机文件重置回默认值,请执行以下步骤:
1. 打开 记事本。 为此,请搜索“记事本”,然后点击或单击 记事本 图标。
2. 复制以下文本,然后将文本粘贴到 文件中:
-
# Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
3. 在“ 文件 ”菜单上,选择“另存为”,在“ 文件名 ”框中键入“主机”, (如下图所示) ,然后将文件保存到桌面。
4. 关闭记事本。
5.搜索 %WinDir%\System32\Drivers\Etc,然后选择“ 文件”文件夹 图标。
6. 点击并按住或右键单击“主机”文件,选择“ 重命名”,然后将该文件重命名为“Hosts.old”。
7. 将步骤 3 中创建的 Hosts 文件从桌面复制或移动到 %WinDir%\System32\Drivers\Etc 文件夹。 根据提示输入管理员密码,选择“继续”。
若要将主机文件重置回默认值,请执行以下步骤:
1. 打开记事本。 为此,请使用 Cortana 搜索“记事本”,然后点击或单击 记事本 图标。
2. 复制以下文本,然后将文本粘贴到 文件中:
-
# Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
3. 在“ 文件 ”菜单上,选择“另存为”,在“ 文件名 ”框中键入“主机”, (如下图所示) ,然后将文件保存到桌面。
4. 关闭记事本。
5. 使用 Cortana 搜索 %WinDir%\System32\Drivers\Etc,然后选择“文件”文件夹图标。
6. 点击并按住或右键单击“主机”文件,选择“ 重命名”,然后将该文件重命名为“Hosts.old”。
7. 将步骤 3 中创建的 Hosts 文件从桌面复制或移动到 %WinDir%\System32\Drivers\Etc 文件夹。 根据提示输入管理员密码,选择“继续”。
若要将主机文件重置回默认值,请执行以下步骤:
1. 打开记事本。 为此,请从屏幕右边缘向内轻扫,点击“ 搜索”,键入记事本,然后点击 记事本 图标。 或者,如果使用鼠标,请指向屏幕右上角,向下移动鼠标指针,单击“ 搜索”,键入“记事本”,然后单击“ 记事本”。
2. 复制以下文本,然后将文本粘贴到 文件中:
-
# Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
3. 在“ 文件 ”菜单上,选择“另存为”,在“ 文件名 ”框中键入“主机”, (如下图所示) ,然后将文件保存到桌面。
4. 关闭记事本。
5.打开 %WinDir%\System32\Drivers\Etc 文件夹。 为此,请按照下列步骤操作:
-
a. 从屏幕右边缘向内轻扫,点击“ 搜索”,键入“运行”,然后点击“ 运行” 图标。 或者,如果使用鼠标,请指向屏幕右上角,向下移动鼠标指针,选择“搜索”,键入“运行”,然后选择“ 运行” 图标。
-
b. 在“打开”框中键入 %WinDir%\System32\Drivers\Etc,然后选择“确定”。
6.选择“主机”文件,选择“重命名”,然后将文件重命名为“Hosts.old”。
7. 将步骤 3 中创建的 Hosts 文件复制或移动到 %WinDir%\System32\Drivers\Etc 文件夹。 根据提示输入管理员密码,点按或单击“继续”。
若要自行将主机文件重置回默认值,请执行以下步骤:
-
单击 “开始”,单击“ 运行”,键入 Notepad,然后单击“ 确定”。
-
从以下列表中查找你的 Windows 版本,然后复制该版本的 Windows 的以下文本,然后将其粘贴到记事本中:
-
对于 Windows 7:
- # Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
-
对于 Windows Vista 或 Windows Server 2008:
- # Copyright (c) 1993-2006 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 ::1 localhost
-
对于 Windows XP 或 Windows Server 2003:
- # 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
3.在“ 文件 ”菜单上,选择“另存为”,在“ 文件名 ”框中键入“主机”,然后将该文件保存到桌面。
4.选择“开始 >运行”,键入 %WinDir%\System32\Drivers\Etc,然后选择“确定”。
5.选择“主机”文件,并将其重命名为“Hosts.old”。
6. 将步骤 3 中创建的 Hosts 文件复制或移动到 %WinDir%\System32\Drivers\Etc 文件夹。 根据提示输入管理员密码,选择“继续”。
更多信息
对 Windows XP 的支持已结束
Microsoft 于 2014 年 4 月 8 日终止了对 Windows XP 的支持。 此更改已影响到了你的软件更新程序和安全选项。 了解这对你意味着什么以及如何保持保护。
对 Windows Server 2003 的支持已于 2015 年 7 月 14 日结束
Microsoft 于 2015 年 7 月 14 日终止了对 Windows Server 2003 的支持。 此更改已影响到了你的软件更新程序和安全选项。 了解这对你意味着什么以及如何保持保护。