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