“Hosts文件丢失/异常,如何还原默认”的版本间的差异

来自电脑维修知识库
跳转至: 导航搜索
 
第23行: 第23行:
  
 
[[文件:hosts文件2.png]]
 
[[文件:hosts文件2.png]]
 
 
也可以直接复制粘贴如下文本到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
 
  
 
[[分类:系统安全]]
 
[[分类:系统安全]]

2024年12月23日 (一) 20:56的最新版本

知识库编号:0982


问题现象

部分情况下,hosts文件出现异常、丢失等情况。

可以参考以下方法进行还原出厂默认hosts。


解决方案

为了以防万一,可以提前备份hosts文件C:\Windows\System32\drivers\etc

Hosts文件1.png

CMD管理员身份运行如下命令:(提示覆盖输入yes)输入完成之后需要等待一段时间


for /f %P in ('dir %windir%\\WinSxS\\hosts /b /s') do copy %P %windir%\\System32\\drivers\\etc & echo %P & Notepad %P


Hosts文件2.png