Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows 綜合教學 >> 關於 Windows

Win7 hosts 檔案位置與修改教學:指定網站 IP、封鎖廣告/惡意網站、加速 GitHub/Google 訪問

編輯:關於 Windows

Windows `hosts` 檔案(`C:\Windows\System32\drivers\etc\hosts`)是本機 DNS 解析對照表,優先級高於網路 DNS 伺服器。善用它可實現網站 IP 指定、廣告攔截、惡意網站封鎖、加速特定服務訪問等功能。

快速開啟 hosts 檔案

  1. `Win+R` → 輸入 `C:\Windows\System32\drivers\etc` → 確定。
  2. 找到 `hosts` 檔案(無副檔名) → 右鍵 → 「開啟方式」 → 選「記事本」(勾選「永遠使用這個應用程式開啟」)。

常用修改範例

1. 指定網站 IP(加速訪問/繞過 DNS 汙染)

格式:`IP位址 域名`(中間以空白或 Tab 分隔)

119.188.139.154 www.jb51.net
140.82.112.4 github.com
142.250.190.46 www.google.com

2. 封鎖指定網站(導向本機回環)

127.0.0.1 ads.example.com
127.0.0.1 tracker.analytics.com
127.0.0.1 m.jb51.net

3. 區域網路裝置別名(方便 SSH/遠端桌面)

192.168.1.100 nas-server
192.168.1.200 printer-office

生效與驗證

  • 儲存 `hosts` 後立即生效(無需重啟)。
  • `Win+R` → `cmd` → `ping 域名` 驗證解析 IP 是否為指定值。
  • 瀏覽器清除 DNS 快取(`chrome://net-internals/#dns` → Clear host cache)後重新訪問。

進階應用與資源

  • **廣告攔截清單**:MVPS HOSTS、StevenBlack/hosts 定期更新,可直接替換系統 hosts。
  • **管理工具**:HostsMan、SwitchHosts! 圖形化管理多組 hosts 設定檔,一鍵切換。
  • **權限問題**:修改 hosts 需管理員權限,記事本請以「系統管理員身分執行」開啟。

掌握 hosts 修改,掌控本機網路解析主導權。

Copyright © Windows教程網 All Rights Reserved