什么是Hosts文件?
Hosts文件是操作系统中一个重要的映射文件,它将域名直接映射到IP地址。当您访问某个网站时,系统会优先查询Hosts文件中的记录,然后再进行DNS解析。
某些软件或病毒可能会修改您的Hosts文件,导致网站无法访问、跳转到广告页面等问题。
为什么需要还原Hosts文件?
- 无法访问某些正常网站
- 打开网站时跳转到广告页面
- 浏览器提示连接不安全
- 安装了某些软件后网络异常
- 怀疑电脑中了恶意软件
重要提示:修改系统文件前建议备份当前状态,操作需要管理员权限。
一键还原方法
方法一:使用脚本一键还原(推荐)
点击下方按钮下载并运行还原脚本:
使用步骤:
- 下载还原工具
- 右键以管理员身份运行
- 按照提示完成操作
- 重启浏览器测试
方法二:手动还原步骤
如果您更倾向于手动操作,请按以下步骤进行:
- 按下
Win + R
键,输入notepad
,然后按Ctrl+Shift+Enter
以管理员身份运行记事本 - 在记事本中,点击"文件" -> "打开"
- 导航到
C:\Windows\System32\drivers\etc\
- 选择"所有文件",打开
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 .0.0.1 localhost ::1 localhost
ipconfig /flushdns
刷新DNS缓存
完成!您的Hosts文件已恢复默认状态,网络问题应该得到解决。
常见问题
提示"访问被拒绝"怎么办?
请确保您是以管理员身份运行记事本或还原工具。右键点击程序选择"以管理员身份运行"。
还原后仍无法上网?
请检查您的网络连接,尝试重启路由器,或联系网络服务提供商。
需要保留某些自定义映射怎么办?
您可以保留必要的映射记录,只需删除可疑或不需要的条目即可。
如何防止Hosts文件再次被修改?
建议安装可靠的杀毒软件,避免安装来路不明的软件,定期检查系统安全。