瀏覽器輸入網址打不開,但直接輸入 IP 卻能連線,十之八九是 DNS 解析出問題。本文從零開始,教您用系統內建工具在四步驟內定位並解決大多數解析故障。
現象:ping www.example.com 失敗/解析超時,ping 203.0.113.10 正常。
C:\> nslookup
Default Server: dns.isp.net
Address: 202.106.0.20
> www.example.com
Server: dns.isp.net
Address: 202.106.0.20
*** Request to dns.isp.net timed-out
出現 timed-out 或 Non-existent domain 即確認為 DNS 解析失敗;若回傳正確 IP 則問題在瀏覽器/代理/防火牆。
C:\> ipconfig /all
...
DNS Servers . . . . . . . . . . . : 202.106.0.20
202.106.46.151
Windows 會快取解析結果(TTL 內不再查詢),若權威端已變更 IP,舊快取會導致解析錯誤。
C:\> ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
緊接著再次 nslookup 或瀏覽器重整,即可取得最新解析。
Hosts 優先級高於 DNS,適用於:
C:\Windows\System32\drivers\etc\hostsC:\Windows\hosts# IP 域名
211.153.80.1 www.ftedu.gov.cn
10.82.0.1 www.ftedu.gov.cn # 內網解析
存檔即時生效,無需重開機。測試:ping www.ftedu.gov.cn 應回傳對應 IP。
| 方向 | 指令/動作 |
|---|---|
| 檢查防火牆/安全軟體攔截 UDP 53 | 暫停防火牆測試;telnet dns.ip 53 不通則為埠阻斷 |
| 驗證 DNS 劫持/汙染 | nslookup www.google.com 8.8.8.8 對比預設 DNS 回傳 |
| IPv6 干擾 | 網卡屬性取消勾選 IPv6,或 netsh interface ipv6 set global randomizeidentifiers=disabled |
| 檢查 TCP/IP 協議損壞 | netsh winsock reset + netsh int ip reset 重開機 |