(1)什么是Hosts文件?
Hosts是一個沒有擴展名的系統(tǒng)文件,可以用記事本等工具打開,其作用就是將一些常用的網(wǎng)址域名與其對應(yīng)的IP地址建立一個關(guān)聯(lián)“數(shù)據(jù)庫”,當(dāng)用戶在瀏覽器中輸入一個需要登錄的網(wǎng)址時,系統(tǒng)會首先自動從Hosts文件中尋找對應(yīng)的IP地址,一旦找到,系統(tǒng)會立即打開對應(yīng)網(wǎng)頁,如果沒有找到,則系統(tǒng)再會將網(wǎng)址提交DNS域名解析服務(wù)器進(jìn)行IP地址的解析。
(2)為什么進(jìn)行Hosts 文件修復(fù)?
很多病毒會修改Hosts文件,例如:把Baidu、Google等常用地址均指向病毒網(wǎng)站,只要你上網(wǎng)搜索,自然會中毒!也會利用修改Hosts文件把購物、銀行等網(wǎng)站指向釣魚網(wǎng)站,盜取您的賬號密碼。更有甚者,病毒會通過修改Hosts使您無法訪問殺毒軟件官網(wǎng),無法下載殺毒軟件進(jìn)行查殺,所以Hosts文件修復(fù)非常重要。
hosts文件位置:
hosts所在文件夾:
Windows 系統(tǒng)hosts位于 C:\Windows\System32\drivers\etc\hosts
Android(安卓)系統(tǒng)hosts位于 /system/etc/hosts
Mac(蘋果電腦)系統(tǒng)hosts跟Linux一樣位于 /etc/hosts
iPhone(iOS)系統(tǒng)hosts跟Linux Mac一樣位于 /etc/hosts
Linux系統(tǒng)hosts位于 /etc/hosts
你也可以用Notepad++ 自行轉(zhuǎn)換文本編碼和換行符格式。有時候殺毒會報毒,請將殺毒暫時停止或允許即可。
修改hosts后生效的方法:
Windows
開始 -> 運行 -> 輸入cmd -> 在CMD窗口輸入
ipconfig /flushdns
Linux
終端輸入
sudo rcnscd restart
對于systemd發(fā)行版,請使用命令
sudo systemctl restart NetworkManager
如果不懂請都嘗試下
Mac OS X終端輸入
sudo killall -HUP mDNSResponder
Android
開啟飛行模式 -> 關(guān)閉飛行模式
通用方法
拔網(wǎng)線(斷網(wǎng)) -> 插網(wǎng)線(重新連接網(wǎng)絡(luò))
(有時候不需要這么做也可以的,反正老D很少刷新DNS,刷新可以更快的解析)
hosts 文件內(nèi)容:
# 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文件 被病毒 木馬修改,可復(fù)制以上內(nèi)容修復(fù)hosts 文件。
本地通過hosts實現(xiàn)屏蔽網(wǎng)站,例如我們想屏蔽或你想本地流量cctv.com為本地網(wǎng)站,可以在后面添加
127.0.0.1 cctv.com
注:ip與域名直接需要用tab鍵隔開