osts文件是windows系統(tǒng)中一個非常重要的文件,無論你使用的是XP、win7,亦或者是win8、win10,都會有hosts文件文件,hosts文件主要作用是加快某個域名或者是網(wǎng)站的解析速度,從而達到快速訪問的作用。當(dāng)然也可以用來屏蔽某些網(wǎng)站。那么hosts文件配置異常如何修復(fù)?今天小編就來給大家分享一下兩種簡單修復(fù)hosts文件配置的方法。
方法一:使用電腦安全軟件修復(fù)
現(xiàn)在的電腦安全軟件功能十分豐富,例如火絨安全軟件、360安全軟件等都有修復(fù)hosts文件的功能,十分適合不太喜歡折騰電腦的小白用戶使用,不過安全軟件也比較吃內(nèi)存,并且有些安全軟件比較“流氓”,安裝后無法卸載干凈。
方法二:直接找到hosts文件,刪除掉hosts文件內(nèi)的數(shù)據(jù)
hosts文件路徑:C:\Windows\System32\drivers\etc,按照小編給的這個路徑,找到hosts文件,用記事本程序打開,然后刪掉里面無關(guān)的域名或者IP(不懂的用戶刪掉全部數(shù)據(jù)),然后保存即可。
以上就是小編介紹的hosts文件配置異常如何修復(fù)的方法了,更多好用的電腦知識盡在莫回首系統(tǒng)官網(wǎng)。
在Windows系統(tǒng)中,有一個叫hosts的系統(tǒng)文件,可以用它進行本地IP地址映射,文件的原始內(nèi)容如下:
# 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
設(shè)置本地IP地址映射后,可以簡化一些操作,比如ping命令,ssh命令。這個特點對于做編程或網(wǎng)路的場景比較實用。比如,開發(fā)人員可能在自己的電腦上部署幾臺虛擬機作為測試環(huán)境,經(jīng)常需要用ssh命令連接虛擬機或者使用ping命令測試網(wǎng)絡(luò)測試虛擬機的網(wǎng)絡(luò)情況。我的頻道會及時的整理出windows操作的技巧和實用方法,喜歡的朋友可以關(guān)注,點贊,收藏,分享給朋友。
在Win11系統(tǒng)中,映射文件的位置在C:\Windows\System32\drivers\etc目錄下,其它Windows系統(tǒng)的位置可能會略有不同。
1. 在文件的最后加入,每個映射關(guān)系占一行。
2. IP地址在前面,后面是機器名,IP地址和機器名之間最少要有一個空格。
3. `#` 號后面的內(nèi)容是注釋,可以獨占一行,也可以跟在設(shè)置的后面。
4. hosts屬于系統(tǒng)文件,修改時,需要使用管理員權(quán)限才能保存。
5. 保存完成后即刻生效。
IP地址 映射字符串
例如,我給自己的電腦上加入一條設(shè)置`192.168.100.71 combo71`,就是將192.168.100.71這個地址與combo71這個字符串建立了對應(yīng)關(guān)系,當(dāng)然,為了實用考慮,這個字符串一般是局域網(wǎng)內(nèi)某臺機器的機器名或是域名。修改后的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
# 虛擬機上的機器
192.168.100.71 combo71
設(shè)置成功后 ping 192.168.100.71的效果和ping combo71對 效果是一樣的。如下:
C:\Users\80771>ping 192.168.100.71
正在 Ping 192.168.100.71 具有 32 字節(jié)的數(shù)據(jù):
來自 192.168.100.71 的回復(fù): 字節(jié)=32 時間<1ms TTL=64
來自 192.168.100.71 的回復(fù): 字節(jié)=32 時間<1ms TTL=64
來自 192.168.100.71 的回復(fù): 字節(jié)=32 時間<1ms TTL=64
來自 192.168.100.71 的回復(fù): 字節(jié)=32 時間<1ms TTL=64
192.168.100.71 的 Ping 統(tǒng)計信息:
數(shù)據(jù)包: 已發(fā)送=4,已接收=4,丟失=0 (0% 丟失),
往返行程的估計時間(以毫秒為單位):
最短=0ms,最長=0ms,平均=0ms
C:\Users\80771>ping combo71
正在 Ping combo71 [192.168.100.71] 具有 32 字節(jié)的數(shù)據(jù):
來自 192.168.100.71 的回復(fù): 字節(jié)=32 時間<1ms TTL=64
來自 192.168.100.71 的回復(fù): 字節(jié)=32 時間<1ms TTL=64
來自 192.168.100.71 的回復(fù): 字節(jié)=32 時間<1ms TTL=64
來自 192.168.100.71 的回復(fù): 字節(jié)=32 時間<1ms TTL=64
192.168.100.71 的 Ping 統(tǒng)計信息:
數(shù)據(jù)包: 已發(fā)送=4,已接收=4,丟失=0 (0% 丟失),
往返行程的估計時間(以毫秒為單位):
最短=0ms,最長=0ms,平均=0ms
感謝閱讀到最后,關(guān)注我,持續(xù)給您帶來簡單,實用的Windows操作技巧。