本文提供另一組使用 netsh 指令在 Windows 10 設定靜態 IP 的完整流程,適合偏好命令列操作的進階使用者或自動化腳本撰寫。
ipconfig 記下目前 IP、子網路遮罩、閘道、DNS。
rem 1. 設定靜態 IP (介面名稱需對應實際名稱,如「乙太網路」)
netsh interface ipv4 set address name="乙太網路" static 192.168.1.50 255.255.255.0 192.168.1.1 1
rem 2. 設定慣用 DNS
netsh interface ipv4 set dns name="乙太網路" static 1.1.1.1 primary
rem 3. 設定備用 DNS
netsh interface ipv4 add dns name="乙太網路" 1.0.0.1 index=2
rem 4. 驗證
ipconfig /all
netsh interface ipv4 set address name="乙太網路" source=dhcp
netsh interface ipv4 set dns name="乙太網路" source=dhcp
提醒:介面名稱請以 netsh interface ipv4 show config 確認,中文版系統通常為「乙太網路」或「Wi-Fi」;英文版為 "Ethernet"、"Wi-Fi"。