首页 > 系统 > Windows > 正文

hosts文件位置、hosts文件是什么?hosts文件修复方法的详细介绍

2019-11-28 05:14:11
字体:
来源:转载
供稿:网友

(1)什么是Hosts文件?

Hosts是一个没有扩展名的系统文件,可以用记事本等工具打开,其作用就是将一些常用的网址域名与其对应的IP地址建立一个关联“数据库”,当用户在浏览器中输入一个需要登录的网址时,系统会首先自动从Hosts文件中寻找对应的IP地址,一旦找到,系统会立即打开对应网页,如果没有找到,则系统再会将网址提交DNS域名解析服务器进行IP地址的解析。

(2)为什么进行Hosts 文件修复?

很多病毒会修改Hosts文件,例如:把Baidu、Google等常用地址均指向病毒网站,只要你上网搜索,自然会中毒!也会利用修改Hosts文件把购物、银行等网站指向钓鱼网站,盗取您的账号密码。更有甚者,病毒会通过修改Hosts使您无法访问杀毒软件官网,无法下载杀毒软件进行查杀,所以Hosts文件修复非常重要。

hosts文件位置:
hosts所在文件夹:
Windows 系统hosts位于 C:/Windows/System32/drivers/etc/hosts
Android(安卓)系统hosts位于 /system/etc/hosts
Mac(苹果电脑)系统hosts跟Linux一样位于 /etc/hosts
iPhone(iOS)系统hosts跟Linux Mac一样位于 /etc/hosts
Linux系统hosts位于 /etc/hosts
你也可以用Notepad++ 自行转换文本编码和换行符格式。有时候杀毒会报毒,请将杀毒暂时停止或允许即可。

修改hosts后生效的方法:


Windows
开始 -> 运行 -> 输入cmd -> 在CMD窗口输入

ipconfig /flushdns

Linux
终端输入

sudo rcnscd restart

对于systemd发行版,请使用命令

sudo systemctl restart NetworkManager

如果不懂请都尝试下

Mac OS X终端输入

sudo killall -HUP mDNSResponder

Android
开启飞行模式 -> 关闭飞行模式

通用方法
拔网线(断网) -> 插网线(重新连接网络)
(有时候不需要这么做也可以的,反正老D很少刷新DNS,刷新可以更快的解析)

hosts 文件内容:
# 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
如果你怀疑你的hosts文件 被病毒 木马修改,可复制以上内容修复hosts 文件。

本地通过hosts实现屏蔽网站,例如我们想屏蔽或你想本地流量cctv.com为本地网站,可以在后面添加
127.0.0.1 cctv.com
注:ip与域名直接需要用tab键隔开

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表