hosts 是無副檔名的系統文字檔,作為本機 DNS 快取對應表,優先於外部 DNS 伺服器解析網域。善用它可加速存取、封鎖廣告/惡意網站、測試開發環境網域對應。

hosts 檔案。hosts 將域名指向 127.0.0.1 或 0.0.0.0 → 達到封鎖效果。路徑: C:\Windows\System32\drivers\etc\hosts
預設內容:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# 127.0.0.1 localhost
# ::1 localhost
C:\Windows\System32\drivers\etc\hosts → 檔案類型選「所有檔案」 → 開啟。IP位址 域名 # 註解127.0.0.1 ad.example.com # 封鎖廣告伺服器192.168.1.50 dev.local # 區域網開發測試::1 對應。chrome://net-internals/#dns)可能導致變更延遲生效,可清除快取。