Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Win7 清理 hosts 檔案完整教學:定位路徑、記事本編輯、還原預設內容、防範惡意篡改

編輯:Win7 系統應用技巧

hosts 檔案 (C:\Windows\System32\drivers\etc\hosts) 是本機 DNS 解析對照表,常被惡意軟體、廣告軟體、駭客程式竄改導致:網站導向錯誤 IP、無法訪問特定網站、釣魚網站重導。定期檢查並還原預設內容是維護網路安全的基本功。本文提供定位、編輯、還原完整步驟。

操作步驟

  1. 開啟「電腦」/「資源管理器」。
  2. 網址列直接輸入路徑並按 Enter:
    C:\Windows\System32\drivers\etc\hosts
  3. 彈出「開啟方式」選擇「記事本」(Notepad)。
  4. 檢視檔案內容:前段為註解說明 (以 # 開頭),預設僅含:
    # Copyright (c) 1993-2006 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
    

  5. 若發現預設註解外有**額外 IP 對應行** (如 127.0.0.1 www.google.com、0.0.0.0 activate.adobe.com 等),即為被竄改。
  6. 清理方法:全選內容刪除 → 貼上上方標準預設內容 → Ctrl+S 儲存。
    注意:儲存需管理員權限。若記事本提示無法儲存,請以管理員身分開啟記事本:開始 → 搜尋「記事本」 → 右鍵 →「以管理員身分執行」 → 開啟 hosts 檔編輯儲存。

常見惡意竄改模式

模式範例目的
阻擋官方更新/驗證0.0.0.0 activate.adobe.com
127.0.0.1 validation.sls.microsoft.com
破解軟體繞過授權驗證
導向釣魚/惡意站192.168.1.100 www.bank.com竊取帳號密碼/植入惡意碼
阻擋廣告/追蹤127.0.0.1 ads.googleanalytics.com某些去廣告軟體行為 (可保留)
區域鎖定繞過127.0.0.1 geo.drm.nintendo.com遊戲主機/服務區域限制繞過

防範建議

  • 安裝可信防毒軟體並啟用即時防護。
  • 不隨意執行來源不明的 .exe/.bat/.reg 檔案。
  • 定期檢查 hosts 檔案 (建議每月或懷疑中毒時)。
  • 將 hosts 檔案設為「唯讀」 (右鍵內容 → 勾選「唯讀」) 可防範自動竄改,但會阻擋合法修改需求 (需暫時取消唯讀)。
  • 使用 HostsMan、BlueLife Hosts Editor 等專用工具管理,支援備份/還原/鎖定/合併清單。

小結

Win7 hosts 檔案清理:定位路徑 → 記事本開啟 → 對照預設內容 → 移除異常對應行 → 管理員權限儲存。養成定期檢查習慣,配合防毒軟體與唯讀屬性,可有效防範惡意 DNS 劫持。

Copyright © Windows教程網 All Rights Reserved