Win7/8/10 Mac中hosts文件位置介紹 Mac Linux中hosts文件修改方法
Hosts是一個沒有擴展名的系統文件,其作用就是將一些常用的網址域名與其對應的IP地址建立一個關聯“數據庫”,可以用記事本打開。當用戶在瀏覽器中輸入一個需要登錄的網址時,系統會首先自動從Hosts文件中尋找對應的IP地址,一旦找到,系統會立即打開對應網頁,如果沒有找到,則系統會再將網址提交DNS域名解析服務器進行IP地址的解析。下面小編就給大家帶來Win7/8/10 Mac中hosts文件位置介紹和Mac Linux中hosts文件修改方法,一起來看看吧!
這就是為什么通過修改hosts文件就可以瀏覽谷歌等被墻網站,原因是直接訪問目標網站對應ip,不通過DNS。
Windows系統hosts位于C:WindowsSystem32driversetchostsAndroid(安卓)系統hosts位于/system/etc/hostsMac(蘋果電腦)系統hosts跟Linux一樣位于/etc/hostsiPhone(iOS)系統hosts跟Linux Mac一樣位于/etc/hostsLinux系統hosts位于/etc/hosts
你可以用記事本打開并修改
PC建議用Notepad++進行編輯。
注意:hosts文件屬于系統核心文件之一,所以Windows用戶必須用管理員身份打開才能修改保存,如果遇到無法保存,請右鍵文件hosts并找到“屬性” -> “安全”,然后選擇你登陸的用戶名,最后點擊編輯,勾選“寫入”即可。
Android(安卓)必須Root才能修改,Root Explorer管理器或ES文件瀏覽器裝載/system可寫狀態,找到/system/etc/hosts的文件,使用文本編輯器打開編輯后保存。
Linux系統使用Root權限vi編輯
而iPhone、iPad也必須越獄才能修改!Windows系統跟蘋果系統的hosts文件文本編碼和換行符格式一樣,而Android(安卓)則不一樣,這點你需要注意。
Windows系統原版hosts文件:
123456789101112131415161718192021 # 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
Mac、iPhone、iPad原版hosts文件:
12345678910 ### Host Database## localhost is used to configure the loopback interface# when the system is booting. Do not change this entry.##127.0.0.1 localhost255.255.255.255 broadcasthost::1localhostfe80::10localhost
Linux系列我就不列出了,一般用這個系統的人都不會是小白。
大家或許留意到,原版的hosts文件前面都帶有井號“#”,以#開頭的都是注釋用的,所以并沒什么卵用,如果你想快速恢復原版hosts文件,那么也可以直接清空里邊的內容,一般情況沒有什么影響。
修改hosts文件后生效的方法:
Windows開始 -> 運行 -> 輸入cmd -> 在CMD窗口輸入:
1 ipconfig /flushdns
Linux終端輸入
1 sudo rcnscd restart
對于systemd發行版,請使用命令
1 sudo systemctl restart NetworkManager
如果不懂請都嘗試下
Mac OS X終端輸入
1 sudo killall -HUP mDNSResponder
Android開啟飛行模式 -> 關閉飛行模式
通用辦法:
拔網線(斷網) -> 插網線(重新連接網絡) 或者重啟系統。
清空瀏覽器緩存(不要使用國產瀏覽器)
以上就是關于Win7/8/10 Mac Linux等各系統的hosts文件位置的介紹了,希望大家喜歡!
